
kernel/kernel:     file format elf64-littleriscv


Disassembly of section .text:

0000000080000000 <_entry>:
    80000000:	00009117          	auipc	sp,0x9
    80000004:	04013103          	ld	sp,64(sp) # 80009040 <_GLOBAL_OFFSET_TABLE_+0x8>
    80000008:	6505                	lui	a0,0x1
    8000000a:	f14025f3          	csrr	a1,mhartid
    8000000e:	0585                	addi	a1,a1,1
    80000010:	02b50533          	mul	a0,a0,a1
    80000014:	912a                	add	sp,sp,a0
    80000016:	072000ef          	jal	ra,80000088 <start>

000000008000001a <junk>:
    8000001a:	a001                	j	8000001a <junk>

000000008000001c <timerinit>:
// which arrive at timervec in kernelvec.S,
// which turns them into software interrupts for
// devintr() in trap.c.
void
timerinit()
{
    8000001c:	1141                	addi	sp,sp,-16
    8000001e:	e422                	sd	s0,8(sp)
    80000020:	0800                	addi	s0,sp,16
// which hart (core) is this?
static inline uint64
r_mhartid()
{
  uint64 x;
  asm volatile("csrr %0, mhartid" : "=r" (x) );
    80000022:	f14027f3          	csrr	a5,mhartid
  // each CPU has a separate source of timer interrupts.
  int id = r_mhartid();
    80000026:	2781                	sext.w	a5,a5

  // ask the CLINT for a timer interrupt.
  int interval = 1000000; // cycles; about 1/10th second in qemu.
  *(uint64*)CLINT_MTIMECMP(id) = *(uint64*)CLINT_MTIME + interval;
    80000028:	0037969b          	slliw	a3,a5,0x3
    8000002c:	02004737          	lui	a4,0x2004
    80000030:	96ba                	add	a3,a3,a4
    80000032:	0200c737          	lui	a4,0x200c
    80000036:	ff873603          	ld	a2,-8(a4) # 200bff8 <_entry-0x7dff4008>
    8000003a:	000f4737          	lui	a4,0xf4
    8000003e:	24070713          	addi	a4,a4,576 # f4240 <_entry-0x7ff0bdc0>
    80000042:	963a                	add	a2,a2,a4
    80000044:	e290                	sd	a2,0(a3)

  // prepare information in scratch[] for timervec.
  // scratch[0..3] : space for timervec to save registers.
  // scratch[4] : address of CLINT MTIMECMP register.
  // scratch[5] : desired interval (in cycles) between timer interrupts.
  uint64 *scratch = &mscratch0[32 * id];
    80000046:	0057979b          	slliw	a5,a5,0x5
    8000004a:	078e                	slli	a5,a5,0x3
    8000004c:	0000a617          	auipc	a2,0xa
    80000050:	fb460613          	addi	a2,a2,-76 # 8000a000 <mscratch0>
    80000054:	97b2                	add	a5,a5,a2
  scratch[4] = CLINT_MTIMECMP(id);
    80000056:	f394                	sd	a3,32(a5)
  scratch[5] = interval;
    80000058:	f798                	sd	a4,40(a5)
}

static inline void 
w_mscratch(uint64 x)
{
  asm volatile("csrw mscratch, %0" : : "r" (x));
    8000005a:	34079073          	csrw	mscratch,a5
  asm volatile("csrw mtvec, %0" : : "r" (x));
    8000005e:	00006797          	auipc	a5,0x6
    80000062:	03278793          	addi	a5,a5,50 # 80006090 <timervec>
    80000066:	30579073          	csrw	mtvec,a5
  asm volatile("csrr %0, mstatus" : "=r" (x) );
    8000006a:	300027f3          	csrr	a5,mstatus

  // set the machine-mode trap handler.
  w_mtvec((uint64)timervec);

  // enable machine-mode interrupts.
  w_mstatus(r_mstatus() | MSTATUS_MIE);
    8000006e:	0087e793          	ori	a5,a5,8
  asm volatile("csrw mstatus, %0" : : "r" (x));
    80000072:	30079073          	csrw	mstatus,a5
  asm volatile("csrr %0, mie" : "=r" (x) );
    80000076:	304027f3          	csrr	a5,mie

  // enable machine-mode timer interrupts.
  w_mie(r_mie() | MIE_MTIE);
    8000007a:	0807e793          	ori	a5,a5,128
  asm volatile("csrw mie, %0" : : "r" (x));
    8000007e:	30479073          	csrw	mie,a5
}
    80000082:	6422                	ld	s0,8(sp)
    80000084:	0141                	addi	sp,sp,16
    80000086:	8082                	ret

0000000080000088 <start>:
{
    80000088:	1141                	addi	sp,sp,-16
    8000008a:	e406                	sd	ra,8(sp)
    8000008c:	e022                	sd	s0,0(sp)
    8000008e:	0800                	addi	s0,sp,16
  asm volatile("csrr %0, mstatus" : "=r" (x) );
    80000090:	300027f3          	csrr	a5,mstatus
  x &= ~MSTATUS_MPP_MASK;
    80000094:	7779                	lui	a4,0xffffe
    80000096:	7ff70713          	addi	a4,a4,2047 # ffffffffffffe7ff <end+0xffffffff7ffce7a3>
    8000009a:	8ff9                	and	a5,a5,a4
  x |= MSTATUS_MPP_S;
    8000009c:	6705                	lui	a4,0x1
    8000009e:	80070713          	addi	a4,a4,-2048 # 800 <_entry-0x7ffff800>
    800000a2:	8fd9                	or	a5,a5,a4
  asm volatile("csrw mstatus, %0" : : "r" (x));
    800000a4:	30079073          	csrw	mstatus,a5
  asm volatile("csrw mepc, %0" : : "r" (x));
    800000a8:	00001797          	auipc	a5,0x1
    800000ac:	00878793          	addi	a5,a5,8 # 800010b0 <main>
    800000b0:	34179073          	csrw	mepc,a5
  asm volatile("csrw satp, %0" : : "r" (x));
    800000b4:	4781                	li	a5,0
    800000b6:	18079073          	csrw	satp,a5
  asm volatile("csrw medeleg, %0" : : "r" (x));
    800000ba:	67c1                	lui	a5,0x10
    800000bc:	17fd                	addi	a5,a5,-1
    800000be:	30279073          	csrw	medeleg,a5
  asm volatile("csrw mideleg, %0" : : "r" (x));
    800000c2:	30379073          	csrw	mideleg,a5
  timerinit();
    800000c6:	00000097          	auipc	ra,0x0
    800000ca:	f56080e7          	jalr	-170(ra) # 8000001c <timerinit>
  asm volatile("csrr %0, mhartid" : "=r" (x) );
    800000ce:	f14027f3          	csrr	a5,mhartid
  w_tp(id);
    800000d2:	2781                	sext.w	a5,a5
}

static inline void 
w_tp(uint64 x)
{
  asm volatile("mv tp, %0" : : "r" (x));
    800000d4:	823e                	mv	tp,a5
  asm volatile("mret");
    800000d6:	30200073          	mret
}
    800000da:	60a2                	ld	ra,8(sp)
    800000dc:	6402                	ld	s0,0(sp)
    800000de:	0141                	addi	sp,sp,16
    800000e0:	8082                	ret

00000000800000e2 <consoleread>:
// user_dist indicates whether dst is a user
// or kernel address.
//
int
consoleread(struct file *f, int user_dst, uint64 dst, int n)
{
    800000e2:	7119                	addi	sp,sp,-128
    800000e4:	fc86                	sd	ra,120(sp)
    800000e6:	f8a2                	sd	s0,112(sp)
    800000e8:	f4a6                	sd	s1,104(sp)
    800000ea:	f0ca                	sd	s2,96(sp)
    800000ec:	ecce                	sd	s3,88(sp)
    800000ee:	e8d2                	sd	s4,80(sp)
    800000f0:	e4d6                	sd	s5,72(sp)
    800000f2:	e0da                	sd	s6,64(sp)
    800000f4:	fc5e                	sd	s7,56(sp)
    800000f6:	f862                	sd	s8,48(sp)
    800000f8:	f466                	sd	s9,40(sp)
    800000fa:	f06a                	sd	s10,32(sp)
    800000fc:	ec6e                	sd	s11,24(sp)
    800000fe:	0100                	addi	s0,sp,128
    80000100:	8cae                	mv	s9,a1
    80000102:	8ab2                	mv	s5,a2
    80000104:	8a36                	mv	s4,a3
  uint target;
  int c;
  char cbuf;

  target = n;
    80000106:	00068b1b          	sext.w	s6,a3
  acquire(&cons.lock);
    8000010a:	00012517          	auipc	a0,0x12
    8000010e:	6f650513          	addi	a0,a0,1782 # 80012800 <cons>
    80000112:	00001097          	auipc	ra,0x1
    80000116:	b34080e7          	jalr	-1228(ra) # 80000c46 <acquire>
  while(n > 0){
    8000011a:	09405663          	blez	s4,800001a6 <consoleread+0xc4>
    // wait until interrupt handler has put some
    // input into cons.buffer.
    while(cons.r == cons.w){
    8000011e:	00012497          	auipc	s1,0x12
    80000122:	6e248493          	addi	s1,s1,1762 # 80012800 <cons>
      if(myproc()->killed){
        release(&cons.lock);
        return -1;
      }
      sleep(&cons.r, &cons.lock);
    80000126:	89a6                	mv	s3,s1
    80000128:	00012917          	auipc	s2,0x12
    8000012c:	77890913          	addi	s2,s2,1912 # 800128a0 <cons+0xa0>
    }

    c = cons.buf[cons.r++ % INPUT_BUF];

    if(c == C('D')){  // end-of-file
    80000130:	4c11                	li	s8,4
      break;
    }

    // copy the input byte to the user-space buffer.
    cbuf = c;
    if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
    80000132:	5d7d                	li	s10,-1
      break;

    dst++;
    --n;

    if(c == '\n'){
    80000134:	4da9                	li	s11,10
    while(cons.r == cons.w){
    80000136:	0a04a783          	lw	a5,160(s1)
    8000013a:	0a44a703          	lw	a4,164(s1)
    8000013e:	02f71463          	bne	a4,a5,80000166 <consoleread+0x84>
      if(myproc()->killed){
    80000142:	00002097          	auipc	ra,0x2
    80000146:	ac4080e7          	jalr	-1340(ra) # 80001c06 <myproc>
    8000014a:	5d1c                	lw	a5,56(a0)
    8000014c:	eba5                	bnez	a5,800001bc <consoleread+0xda>
      sleep(&cons.r, &cons.lock);
    8000014e:	85ce                	mv	a1,s3
    80000150:	854a                	mv	a0,s2
    80000152:	00002097          	auipc	ra,0x2
    80000156:	290080e7          	jalr	656(ra) # 800023e2 <sleep>
    while(cons.r == cons.w){
    8000015a:	0a04a783          	lw	a5,160(s1)
    8000015e:	0a44a703          	lw	a4,164(s1)
    80000162:	fef700e3          	beq	a4,a5,80000142 <consoleread+0x60>
    c = cons.buf[cons.r++ % INPUT_BUF];
    80000166:	0017871b          	addiw	a4,a5,1
    8000016a:	0ae4a023          	sw	a4,160(s1)
    8000016e:	07f7f713          	andi	a4,a5,127
    80000172:	9726                	add	a4,a4,s1
    80000174:	02074703          	lbu	a4,32(a4)
    80000178:	00070b9b          	sext.w	s7,a4
    if(c == C('D')){  // end-of-file
    8000017c:	078b8863          	beq	s7,s8,800001ec <consoleread+0x10a>
    cbuf = c;
    80000180:	f8e407a3          	sb	a4,-113(s0)
    if(either_copyout(user_dst, dst, &cbuf, 1) == -1)
    80000184:	4685                	li	a3,1
    80000186:	f8f40613          	addi	a2,s0,-113
    8000018a:	85d6                	mv	a1,s5
    8000018c:	8566                	mv	a0,s9
    8000018e:	00002097          	auipc	ra,0x2
    80000192:	4b6080e7          	jalr	1206(ra) # 80002644 <either_copyout>
    80000196:	01a50863          	beq	a0,s10,800001a6 <consoleread+0xc4>
    dst++;
    8000019a:	0a85                	addi	s5,s5,1
    --n;
    8000019c:	3a7d                	addiw	s4,s4,-1
    if(c == '\n'){
    8000019e:	01bb8463          	beq	s7,s11,800001a6 <consoleread+0xc4>
  while(n > 0){
    800001a2:	f80a1ae3          	bnez	s4,80000136 <consoleread+0x54>
      // a whole line has arrived, return to
      // the user-level read().
      break;
    }
  }
  release(&cons.lock);
    800001a6:	00012517          	auipc	a0,0x12
    800001aa:	65a50513          	addi	a0,a0,1626 # 80012800 <cons>
    800001ae:	00001097          	auipc	ra,0x1
    800001b2:	b08080e7          	jalr	-1272(ra) # 80000cb6 <release>

  return target - n;
    800001b6:	414b053b          	subw	a0,s6,s4
    800001ba:	a811                	j	800001ce <consoleread+0xec>
        release(&cons.lock);
    800001bc:	00012517          	auipc	a0,0x12
    800001c0:	64450513          	addi	a0,a0,1604 # 80012800 <cons>
    800001c4:	00001097          	auipc	ra,0x1
    800001c8:	af2080e7          	jalr	-1294(ra) # 80000cb6 <release>
        return -1;
    800001cc:	557d                	li	a0,-1
}
    800001ce:	70e6                	ld	ra,120(sp)
    800001d0:	7446                	ld	s0,112(sp)
    800001d2:	74a6                	ld	s1,104(sp)
    800001d4:	7906                	ld	s2,96(sp)
    800001d6:	69e6                	ld	s3,88(sp)
    800001d8:	6a46                	ld	s4,80(sp)
    800001da:	6aa6                	ld	s5,72(sp)
    800001dc:	6b06                	ld	s6,64(sp)
    800001de:	7be2                	ld	s7,56(sp)
    800001e0:	7c42                	ld	s8,48(sp)
    800001e2:	7ca2                	ld	s9,40(sp)
    800001e4:	7d02                	ld	s10,32(sp)
    800001e6:	6de2                	ld	s11,24(sp)
    800001e8:	6109                	addi	sp,sp,128
    800001ea:	8082                	ret
      if(n < target){
    800001ec:	000a071b          	sext.w	a4,s4
    800001f0:	fb677be3          	bleu	s6,a4,800001a6 <consoleread+0xc4>
        cons.r--;
    800001f4:	00012717          	auipc	a4,0x12
    800001f8:	6af72623          	sw	a5,1708(a4) # 800128a0 <cons+0xa0>
    800001fc:	b76d                	j	800001a6 <consoleread+0xc4>

00000000800001fe <consputc>:
  if(panicked){
    800001fe:	00030797          	auipc	a5,0x30
    80000202:	e2278793          	addi	a5,a5,-478 # 80030020 <panicked>
    80000206:	439c                	lw	a5,0(a5)
    80000208:	2781                	sext.w	a5,a5
    8000020a:	c391                	beqz	a5,8000020e <consputc+0x10>
    for(;;)
    8000020c:	a001                	j	8000020c <consputc+0xe>
{
    8000020e:	1141                	addi	sp,sp,-16
    80000210:	e406                	sd	ra,8(sp)
    80000212:	e022                	sd	s0,0(sp)
    80000214:	0800                	addi	s0,sp,16
  if(c == BACKSPACE){
    80000216:	10000793          	li	a5,256
    8000021a:	00f50a63          	beq	a0,a5,8000022e <consputc+0x30>
    uartputc(c);
    8000021e:	00000097          	auipc	ra,0x0
    80000222:	608080e7          	jalr	1544(ra) # 80000826 <uartputc>
}
    80000226:	60a2                	ld	ra,8(sp)
    80000228:	6402                	ld	s0,0(sp)
    8000022a:	0141                	addi	sp,sp,16
    8000022c:	8082                	ret
    uartputc('\b'); uartputc(' '); uartputc('\b');
    8000022e:	4521                	li	a0,8
    80000230:	00000097          	auipc	ra,0x0
    80000234:	5f6080e7          	jalr	1526(ra) # 80000826 <uartputc>
    80000238:	02000513          	li	a0,32
    8000023c:	00000097          	auipc	ra,0x0
    80000240:	5ea080e7          	jalr	1514(ra) # 80000826 <uartputc>
    80000244:	4521                	li	a0,8
    80000246:	00000097          	auipc	ra,0x0
    8000024a:	5e0080e7          	jalr	1504(ra) # 80000826 <uartputc>
    8000024e:	bfe1                	j	80000226 <consputc+0x28>

0000000080000250 <consolewrite>:
{
    80000250:	715d                	addi	sp,sp,-80
    80000252:	e486                	sd	ra,72(sp)
    80000254:	e0a2                	sd	s0,64(sp)
    80000256:	fc26                	sd	s1,56(sp)
    80000258:	f84a                	sd	s2,48(sp)
    8000025a:	f44e                	sd	s3,40(sp)
    8000025c:	f052                	sd	s4,32(sp)
    8000025e:	ec56                	sd	s5,24(sp)
    80000260:	0880                	addi	s0,sp,80
    80000262:	89ae                	mv	s3,a1
    80000264:	84b2                	mv	s1,a2
    80000266:	8ab6                	mv	s5,a3
  acquire(&cons.lock);
    80000268:	00012517          	auipc	a0,0x12
    8000026c:	59850513          	addi	a0,a0,1432 # 80012800 <cons>
    80000270:	00001097          	auipc	ra,0x1
    80000274:	9d6080e7          	jalr	-1578(ra) # 80000c46 <acquire>
  for(i = 0; i < n; i++){
    80000278:	03505e63          	blez	s5,800002b4 <consolewrite+0x64>
    8000027c:	00148913          	addi	s2,s1,1
    80000280:	fffa879b          	addiw	a5,s5,-1
    80000284:	1782                	slli	a5,a5,0x20
    80000286:	9381                	srli	a5,a5,0x20
    80000288:	993e                	add	s2,s2,a5
    if(either_copyin(&c, user_src, src+i, 1) == -1)
    8000028a:	5a7d                	li	s4,-1
    8000028c:	4685                	li	a3,1
    8000028e:	8626                	mv	a2,s1
    80000290:	85ce                	mv	a1,s3
    80000292:	fbf40513          	addi	a0,s0,-65
    80000296:	00002097          	auipc	ra,0x2
    8000029a:	404080e7          	jalr	1028(ra) # 8000269a <either_copyin>
    8000029e:	01450b63          	beq	a0,s4,800002b4 <consolewrite+0x64>
    consputc(c);
    800002a2:	fbf44503          	lbu	a0,-65(s0)
    800002a6:	00000097          	auipc	ra,0x0
    800002aa:	f58080e7          	jalr	-168(ra) # 800001fe <consputc>
  for(i = 0; i < n; i++){
    800002ae:	0485                	addi	s1,s1,1
    800002b0:	fd249ee3          	bne	s1,s2,8000028c <consolewrite+0x3c>
  release(&cons.lock);
    800002b4:	00012517          	auipc	a0,0x12
    800002b8:	54c50513          	addi	a0,a0,1356 # 80012800 <cons>
    800002bc:	00001097          	auipc	ra,0x1
    800002c0:	9fa080e7          	jalr	-1542(ra) # 80000cb6 <release>
}
    800002c4:	8556                	mv	a0,s5
    800002c6:	60a6                	ld	ra,72(sp)
    800002c8:	6406                	ld	s0,64(sp)
    800002ca:	74e2                	ld	s1,56(sp)
    800002cc:	7942                	ld	s2,48(sp)
    800002ce:	79a2                	ld	s3,40(sp)
    800002d0:	7a02                	ld	s4,32(sp)
    800002d2:	6ae2                	ld	s5,24(sp)
    800002d4:	6161                	addi	sp,sp,80
    800002d6:	8082                	ret

00000000800002d8 <consoleintr>:
// do erase/kill processing, append to cons.buf,
// wake up consoleread() if a whole line has arrived.
//
void
consoleintr(int c)
{
    800002d8:	1101                	addi	sp,sp,-32
    800002da:	ec06                	sd	ra,24(sp)
    800002dc:	e822                	sd	s0,16(sp)
    800002de:	e426                	sd	s1,8(sp)
    800002e0:	e04a                	sd	s2,0(sp)
    800002e2:	1000                	addi	s0,sp,32
    800002e4:	84aa                	mv	s1,a0
  acquire(&cons.lock);
    800002e6:	00012517          	auipc	a0,0x12
    800002ea:	51a50513          	addi	a0,a0,1306 # 80012800 <cons>
    800002ee:	00001097          	auipc	ra,0x1
    800002f2:	958080e7          	jalr	-1704(ra) # 80000c46 <acquire>

  switch(c){
    800002f6:	47c1                	li	a5,16
    800002f8:	12f48463          	beq	s1,a5,80000420 <consoleintr+0x148>
    800002fc:	0297df63          	ble	s1,a5,8000033a <consoleintr+0x62>
    80000300:	47d5                	li	a5,21
    80000302:	0af48863          	beq	s1,a5,800003b2 <consoleintr+0xda>
    80000306:	07f00793          	li	a5,127
    8000030a:	02f49b63          	bne	s1,a5,80000340 <consoleintr+0x68>
      consputc(BACKSPACE);
    }
    break;
  case C('H'): // Backspace
  case '\x7f':
    if(cons.e != cons.w){
    8000030e:	00012717          	auipc	a4,0x12
    80000312:	4f270713          	addi	a4,a4,1266 # 80012800 <cons>
    80000316:	0a872783          	lw	a5,168(a4)
    8000031a:	0a472703          	lw	a4,164(a4)
    8000031e:	10f70563          	beq	a4,a5,80000428 <consoleintr+0x150>
      cons.e--;
    80000322:	37fd                	addiw	a5,a5,-1
    80000324:	00012717          	auipc	a4,0x12
    80000328:	58f72223          	sw	a5,1412(a4) # 800128a8 <cons+0xa8>
      consputc(BACKSPACE);
    8000032c:	10000513          	li	a0,256
    80000330:	00000097          	auipc	ra,0x0
    80000334:	ece080e7          	jalr	-306(ra) # 800001fe <consputc>
    80000338:	a8c5                	j	80000428 <consoleintr+0x150>
  switch(c){
    8000033a:	47a1                	li	a5,8
    8000033c:	fcf489e3          	beq	s1,a5,8000030e <consoleintr+0x36>
    }
    break;
  default:
    if(c != 0 && cons.e-cons.r < INPUT_BUF){
    80000340:	c4e5                	beqz	s1,80000428 <consoleintr+0x150>
    80000342:	00012717          	auipc	a4,0x12
    80000346:	4be70713          	addi	a4,a4,1214 # 80012800 <cons>
    8000034a:	0a872783          	lw	a5,168(a4)
    8000034e:	0a072703          	lw	a4,160(a4)
    80000352:	9f99                	subw	a5,a5,a4
    80000354:	07f00713          	li	a4,127
    80000358:	0cf76863          	bltu	a4,a5,80000428 <consoleintr+0x150>
      c = (c == '\r') ? '\n' : c;
    8000035c:	47b5                	li	a5,13
    8000035e:	0ef48363          	beq	s1,a5,80000444 <consoleintr+0x16c>

      // echo back to the user.
      consputc(c);
    80000362:	8526                	mv	a0,s1
    80000364:	00000097          	auipc	ra,0x0
    80000368:	e9a080e7          	jalr	-358(ra) # 800001fe <consputc>

      // store for consumption by consoleread().
      cons.buf[cons.e++ % INPUT_BUF] = c;
    8000036c:	00012797          	auipc	a5,0x12
    80000370:	49478793          	addi	a5,a5,1172 # 80012800 <cons>
    80000374:	0a87a703          	lw	a4,168(a5)
    80000378:	0017069b          	addiw	a3,a4,1
    8000037c:	0006861b          	sext.w	a2,a3
    80000380:	0ad7a423          	sw	a3,168(a5)
    80000384:	07f77713          	andi	a4,a4,127
    80000388:	97ba                	add	a5,a5,a4
    8000038a:	02978023          	sb	s1,32(a5)

      if(c == '\n' || c == C('D') || cons.e == cons.r+INPUT_BUF){
    8000038e:	47a9                	li	a5,10
    80000390:	0ef48163          	beq	s1,a5,80000472 <consoleintr+0x19a>
    80000394:	4791                	li	a5,4
    80000396:	0cf48e63          	beq	s1,a5,80000472 <consoleintr+0x19a>
    8000039a:	00012797          	auipc	a5,0x12
    8000039e:	46678793          	addi	a5,a5,1126 # 80012800 <cons>
    800003a2:	0a07a783          	lw	a5,160(a5)
    800003a6:	0807879b          	addiw	a5,a5,128
    800003aa:	06f61f63          	bne	a2,a5,80000428 <consoleintr+0x150>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    800003ae:	863e                	mv	a2,a5
    800003b0:	a0c9                	j	80000472 <consoleintr+0x19a>
    while(cons.e != cons.w &&
    800003b2:	00012717          	auipc	a4,0x12
    800003b6:	44e70713          	addi	a4,a4,1102 # 80012800 <cons>
    800003ba:	0a872783          	lw	a5,168(a4)
    800003be:	0a472703          	lw	a4,164(a4)
    800003c2:	06f70363          	beq	a4,a5,80000428 <consoleintr+0x150>
          cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
    800003c6:	37fd                	addiw	a5,a5,-1
    800003c8:	0007871b          	sext.w	a4,a5
    800003cc:	07f7f793          	andi	a5,a5,127
    800003d0:	00012697          	auipc	a3,0x12
    800003d4:	43068693          	addi	a3,a3,1072 # 80012800 <cons>
    800003d8:	97b6                	add	a5,a5,a3
    while(cons.e != cons.w &&
    800003da:	0207c683          	lbu	a3,32(a5)
    800003de:	47a9                	li	a5,10
      cons.e--;
    800003e0:	00012497          	auipc	s1,0x12
    800003e4:	42048493          	addi	s1,s1,1056 # 80012800 <cons>
    while(cons.e != cons.w &&
    800003e8:	4929                	li	s2,10
    800003ea:	02f68f63          	beq	a3,a5,80000428 <consoleintr+0x150>
      cons.e--;
    800003ee:	0ae4a423          	sw	a4,168(s1)
      consputc(BACKSPACE);
    800003f2:	10000513          	li	a0,256
    800003f6:	00000097          	auipc	ra,0x0
    800003fa:	e08080e7          	jalr	-504(ra) # 800001fe <consputc>
    while(cons.e != cons.w &&
    800003fe:	0a84a783          	lw	a5,168(s1)
    80000402:	0a44a703          	lw	a4,164(s1)
    80000406:	02f70163          	beq	a4,a5,80000428 <consoleintr+0x150>
          cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){
    8000040a:	37fd                	addiw	a5,a5,-1
    8000040c:	0007871b          	sext.w	a4,a5
    80000410:	07f7f793          	andi	a5,a5,127
    80000414:	97a6                	add	a5,a5,s1
    while(cons.e != cons.w &&
    80000416:	0207c783          	lbu	a5,32(a5)
    8000041a:	fd279ae3          	bne	a5,s2,800003ee <consoleintr+0x116>
    8000041e:	a029                	j	80000428 <consoleintr+0x150>
    procdump();
    80000420:	00002097          	auipc	ra,0x2
    80000424:	2d0080e7          	jalr	720(ra) # 800026f0 <procdump>
      }
    }
    break;
  }
  
  release(&cons.lock);
    80000428:	00012517          	auipc	a0,0x12
    8000042c:	3d850513          	addi	a0,a0,984 # 80012800 <cons>
    80000430:	00001097          	auipc	ra,0x1
    80000434:	886080e7          	jalr	-1914(ra) # 80000cb6 <release>
}
    80000438:	60e2                	ld	ra,24(sp)
    8000043a:	6442                	ld	s0,16(sp)
    8000043c:	64a2                	ld	s1,8(sp)
    8000043e:	6902                	ld	s2,0(sp)
    80000440:	6105                	addi	sp,sp,32
    80000442:	8082                	ret
      consputc(c);
    80000444:	4529                	li	a0,10
    80000446:	00000097          	auipc	ra,0x0
    8000044a:	db8080e7          	jalr	-584(ra) # 800001fe <consputc>
      cons.buf[cons.e++ % INPUT_BUF] = c;
    8000044e:	00012797          	auipc	a5,0x12
    80000452:	3b278793          	addi	a5,a5,946 # 80012800 <cons>
    80000456:	0a87a703          	lw	a4,168(a5)
    8000045a:	0017069b          	addiw	a3,a4,1
    8000045e:	0006861b          	sext.w	a2,a3
    80000462:	0ad7a423          	sw	a3,168(a5)
    80000466:	07f77713          	andi	a4,a4,127
    8000046a:	97ba                	add	a5,a5,a4
    8000046c:	4729                	li	a4,10
    8000046e:	02e78023          	sb	a4,32(a5)
        cons.w = cons.e;
    80000472:	00012797          	auipc	a5,0x12
    80000476:	42c7a923          	sw	a2,1074(a5) # 800128a4 <cons+0xa4>
        wakeup(&cons.r);
    8000047a:	00012517          	auipc	a0,0x12
    8000047e:	42650513          	addi	a0,a0,1062 # 800128a0 <cons+0xa0>
    80000482:	00002097          	auipc	ra,0x2
    80000486:	0e6080e7          	jalr	230(ra) # 80002568 <wakeup>
    8000048a:	bf79                	j	80000428 <consoleintr+0x150>

000000008000048c <consoleinit>:

void
consoleinit(void)
{
    8000048c:	1141                	addi	sp,sp,-16
    8000048e:	e406                	sd	ra,8(sp)
    80000490:	e022                	sd	s0,0(sp)
    80000492:	0800                	addi	s0,sp,16
  initlock(&cons.lock, "cons");
    80000494:	00008597          	auipc	a1,0x8
    80000498:	c8458593          	addi	a1,a1,-892 # 80008118 <userret+0x88>
    8000049c:	00012517          	auipc	a0,0x12
    800004a0:	36450513          	addi	a0,a0,868 # 80012800 <cons>
    800004a4:	00000097          	auipc	ra,0x0
    800004a8:	652080e7          	jalr	1618(ra) # 80000af6 <initlock>

  uartinit();
    800004ac:	00000097          	auipc	ra,0x0
    800004b0:	344080e7          	jalr	836(ra) # 800007f0 <uartinit>

  // connect read and write system calls
  // to consoleread and consolewrite.
  devsw[CONSOLE].read = consoleread;
    800004b4:	00028797          	auipc	a5,0x28
    800004b8:	1dc78793          	addi	a5,a5,476 # 80028690 <devsw>
    800004bc:	00000717          	auipc	a4,0x0
    800004c0:	c2670713          	addi	a4,a4,-986 # 800000e2 <consoleread>
    800004c4:	eb98                	sd	a4,16(a5)
  devsw[CONSOLE].write = consolewrite;
    800004c6:	00000717          	auipc	a4,0x0
    800004ca:	d8a70713          	addi	a4,a4,-630 # 80000250 <consolewrite>
    800004ce:	ef98                	sd	a4,24(a5)
}
    800004d0:	60a2                	ld	ra,8(sp)
    800004d2:	6402                	ld	s0,0(sp)
    800004d4:	0141                	addi	sp,sp,16
    800004d6:	8082                	ret

00000000800004d8 <printint>:

static char digits[] = "0123456789abcdef";

static void
printint(int xx, int base, int sign)
{
    800004d8:	7179                	addi	sp,sp,-48
    800004da:	f406                	sd	ra,40(sp)
    800004dc:	f022                	sd	s0,32(sp)
    800004de:	ec26                	sd	s1,24(sp)
    800004e0:	e84a                	sd	s2,16(sp)
    800004e2:	1800                	addi	s0,sp,48
  char buf[16];
  int i;
  uint x;

  if(sign && (sign = xx < 0))
    800004e4:	c219                	beqz	a2,800004ea <printint+0x12>
    800004e6:	00054d63          	bltz	a0,80000500 <printint+0x28>
    x = -xx;
  else
    x = xx;
    800004ea:	2501                	sext.w	a0,a0
    800004ec:	4881                	li	a7,0
    800004ee:	fd040713          	addi	a4,s0,-48

  i = 0;
    800004f2:	4601                	li	a2,0
  do {
    buf[i++] = digits[x % base];
    800004f4:	2581                	sext.w	a1,a1
    800004f6:	00008817          	auipc	a6,0x8
    800004fa:	5ca80813          	addi	a6,a6,1482 # 80008ac0 <digits>
    800004fe:	a801                	j	8000050e <printint+0x36>
    x = -xx;
    80000500:	40a0053b          	negw	a0,a0
    80000504:	2501                	sext.w	a0,a0
  if(sign && (sign = xx < 0))
    80000506:	4885                	li	a7,1
    x = -xx;
    80000508:	b7dd                	j	800004ee <printint+0x16>
  } while((x /= base) != 0);
    8000050a:	853e                	mv	a0,a5
    buf[i++] = digits[x % base];
    8000050c:	8636                	mv	a2,a3
    8000050e:	0016069b          	addiw	a3,a2,1
    80000512:	02b577bb          	remuw	a5,a0,a1
    80000516:	1782                	slli	a5,a5,0x20
    80000518:	9381                	srli	a5,a5,0x20
    8000051a:	97c2                	add	a5,a5,a6
    8000051c:	0007c783          	lbu	a5,0(a5)
    80000520:	00f70023          	sb	a5,0(a4)
  } while((x /= base) != 0);
    80000524:	0705                	addi	a4,a4,1
    80000526:	02b557bb          	divuw	a5,a0,a1
    8000052a:	feb570e3          	bleu	a1,a0,8000050a <printint+0x32>

  if(sign)
    8000052e:	00088b63          	beqz	a7,80000544 <printint+0x6c>
    buf[i++] = '-';
    80000532:	fe040793          	addi	a5,s0,-32
    80000536:	96be                	add	a3,a3,a5
    80000538:	02d00793          	li	a5,45
    8000053c:	fef68823          	sb	a5,-16(a3)
    80000540:	0026069b          	addiw	a3,a2,2

  while(--i >= 0)
    80000544:	02d05763          	blez	a3,80000572 <printint+0x9a>
    80000548:	fd040793          	addi	a5,s0,-48
    8000054c:	00d784b3          	add	s1,a5,a3
    80000550:	fff78913          	addi	s2,a5,-1
    80000554:	9936                	add	s2,s2,a3
    80000556:	36fd                	addiw	a3,a3,-1
    80000558:	1682                	slli	a3,a3,0x20
    8000055a:	9281                	srli	a3,a3,0x20
    8000055c:	40d90933          	sub	s2,s2,a3
    consputc(buf[i]);
    80000560:	fff4c503          	lbu	a0,-1(s1)
    80000564:	00000097          	auipc	ra,0x0
    80000568:	c9a080e7          	jalr	-870(ra) # 800001fe <consputc>
  while(--i >= 0)
    8000056c:	14fd                	addi	s1,s1,-1
    8000056e:	ff2499e3          	bne	s1,s2,80000560 <printint+0x88>
}
    80000572:	70a2                	ld	ra,40(sp)
    80000574:	7402                	ld	s0,32(sp)
    80000576:	64e2                	ld	s1,24(sp)
    80000578:	6942                	ld	s2,16(sp)
    8000057a:	6145                	addi	sp,sp,48
    8000057c:	8082                	ret

000000008000057e <panic>:
    release(&pr.lock);
}

void
panic(char *s)
{
    8000057e:	1101                	addi	sp,sp,-32
    80000580:	ec06                	sd	ra,24(sp)
    80000582:	e822                	sd	s0,16(sp)
    80000584:	e426                	sd	s1,8(sp)
    80000586:	1000                	addi	s0,sp,32
    80000588:	84aa                	mv	s1,a0
  pr.locking = 0;
    8000058a:	00012797          	auipc	a5,0x12
    8000058e:	3407a323          	sw	zero,838(a5) # 800128d0 <pr+0x20>
  printf("PANIC: ");
    80000592:	00008517          	auipc	a0,0x8
    80000596:	b8e50513          	addi	a0,a0,-1138 # 80008120 <userret+0x90>
    8000059a:	00000097          	auipc	ra,0x0
    8000059e:	03e080e7          	jalr	62(ra) # 800005d8 <printf>
  printf(s);
    800005a2:	8526                	mv	a0,s1
    800005a4:	00000097          	auipc	ra,0x0
    800005a8:	034080e7          	jalr	52(ra) # 800005d8 <printf>
  printf("\n");
    800005ac:	00008517          	auipc	a0,0x8
    800005b0:	ce450513          	addi	a0,a0,-796 # 80008290 <userret+0x200>
    800005b4:	00000097          	auipc	ra,0x0
    800005b8:	024080e7          	jalr	36(ra) # 800005d8 <printf>
  printf("HINT: restart xv6 using 'make qemu-gdb', type 'b panic' (to set breakpoint in panic) in the gdb window, followed by 'c' (continue), and when the kernel hits the breakpoint, type 'bt' to get a backtrace\n");
    800005bc:	00008517          	auipc	a0,0x8
    800005c0:	b6c50513          	addi	a0,a0,-1172 # 80008128 <userret+0x98>
    800005c4:	00000097          	auipc	ra,0x0
    800005c8:	014080e7          	jalr	20(ra) # 800005d8 <printf>
  panicked = 1; // freeze other CPUs
    800005cc:	4785                	li	a5,1
    800005ce:	00030717          	auipc	a4,0x30
    800005d2:	a4f72923          	sw	a5,-1454(a4) # 80030020 <panicked>
  for(;;)
    800005d6:	a001                	j	800005d6 <panic+0x58>

00000000800005d8 <printf>:
{
    800005d8:	7131                	addi	sp,sp,-192
    800005da:	fc86                	sd	ra,120(sp)
    800005dc:	f8a2                	sd	s0,112(sp)
    800005de:	f4a6                	sd	s1,104(sp)
    800005e0:	f0ca                	sd	s2,96(sp)
    800005e2:	ecce                	sd	s3,88(sp)
    800005e4:	e8d2                	sd	s4,80(sp)
    800005e6:	e4d6                	sd	s5,72(sp)
    800005e8:	e0da                	sd	s6,64(sp)
    800005ea:	fc5e                	sd	s7,56(sp)
    800005ec:	f862                	sd	s8,48(sp)
    800005ee:	f466                	sd	s9,40(sp)
    800005f0:	f06a                	sd	s10,32(sp)
    800005f2:	ec6e                	sd	s11,24(sp)
    800005f4:	0100                	addi	s0,sp,128
    800005f6:	8aaa                	mv	s5,a0
    800005f8:	e40c                	sd	a1,8(s0)
    800005fa:	e810                	sd	a2,16(s0)
    800005fc:	ec14                	sd	a3,24(s0)
    800005fe:	f018                	sd	a4,32(s0)
    80000600:	f41c                	sd	a5,40(s0)
    80000602:	03043823          	sd	a6,48(s0)
    80000606:	03143c23          	sd	a7,56(s0)
  locking = pr.locking;
    8000060a:	00012797          	auipc	a5,0x12
    8000060e:	2a678793          	addi	a5,a5,678 # 800128b0 <pr>
    80000612:	0207ad83          	lw	s11,32(a5)
  if(locking)
    80000616:	020d9b63          	bnez	s11,8000064c <printf+0x74>
  if (fmt == 0)
    8000061a:	020a8f63          	beqz	s5,80000658 <printf+0x80>
  va_start(ap, fmt);
    8000061e:	00840793          	addi	a5,s0,8
    80000622:	f8f43423          	sd	a5,-120(s0)
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    80000626:	000ac503          	lbu	a0,0(s5)
    8000062a:	16050063          	beqz	a0,8000078a <printf+0x1b2>
    8000062e:	4481                	li	s1,0
    if(c != '%'){
    80000630:	02500a13          	li	s4,37
    switch(c){
    80000634:	07000b13          	li	s6,112
  consputc('x');
    80000638:	4d41                	li	s10,16
    consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
    8000063a:	00008b97          	auipc	s7,0x8
    8000063e:	486b8b93          	addi	s7,s7,1158 # 80008ac0 <digits>
    switch(c){
    80000642:	07300c93          	li	s9,115
    80000646:	06400c13          	li	s8,100
    8000064a:	a815                	j	8000067e <printf+0xa6>
    acquire(&pr.lock);
    8000064c:	853e                	mv	a0,a5
    8000064e:	00000097          	auipc	ra,0x0
    80000652:	5f8080e7          	jalr	1528(ra) # 80000c46 <acquire>
    80000656:	b7d1                	j	8000061a <printf+0x42>
    panic("null fmt");
    80000658:	00008517          	auipc	a0,0x8
    8000065c:	ba850513          	addi	a0,a0,-1112 # 80008200 <userret+0x170>
    80000660:	00000097          	auipc	ra,0x0
    80000664:	f1e080e7          	jalr	-226(ra) # 8000057e <panic>
      consputc(c);
    80000668:	00000097          	auipc	ra,0x0
    8000066c:	b96080e7          	jalr	-1130(ra) # 800001fe <consputc>
  for(i = 0; (c = fmt[i] & 0xff) != 0; i++){
    80000670:	2485                	addiw	s1,s1,1
    80000672:	009a87b3          	add	a5,s5,s1
    80000676:	0007c503          	lbu	a0,0(a5)
    8000067a:	10050863          	beqz	a0,8000078a <printf+0x1b2>
    if(c != '%'){
    8000067e:	ff4515e3          	bne	a0,s4,80000668 <printf+0x90>
    c = fmt[++i] & 0xff;
    80000682:	2485                	addiw	s1,s1,1
    80000684:	009a87b3          	add	a5,s5,s1
    80000688:	0007c783          	lbu	a5,0(a5)
    8000068c:	0007891b          	sext.w	s2,a5
    if(c == 0)
    80000690:	0e090d63          	beqz	s2,8000078a <printf+0x1b2>
    switch(c){
    80000694:	05678a63          	beq	a5,s6,800006e8 <printf+0x110>
    80000698:	02fb7663          	bleu	a5,s6,800006c4 <printf+0xec>
    8000069c:	09978963          	beq	a5,s9,8000072e <printf+0x156>
    800006a0:	07800713          	li	a4,120
    800006a4:	0ce79863          	bne	a5,a4,80000774 <printf+0x19c>
      printint(va_arg(ap, int), 16, 1);
    800006a8:	f8843783          	ld	a5,-120(s0)
    800006ac:	00878713          	addi	a4,a5,8
    800006b0:	f8e43423          	sd	a4,-120(s0)
    800006b4:	4605                	li	a2,1
    800006b6:	85ea                	mv	a1,s10
    800006b8:	4388                	lw	a0,0(a5)
    800006ba:	00000097          	auipc	ra,0x0
    800006be:	e1e080e7          	jalr	-482(ra) # 800004d8 <printint>
      break;
    800006c2:	b77d                	j	80000670 <printf+0x98>
    switch(c){
    800006c4:	0b478263          	beq	a5,s4,80000768 <printf+0x190>
    800006c8:	0b879663          	bne	a5,s8,80000774 <printf+0x19c>
      printint(va_arg(ap, int), 10, 1);
    800006cc:	f8843783          	ld	a5,-120(s0)
    800006d0:	00878713          	addi	a4,a5,8
    800006d4:	f8e43423          	sd	a4,-120(s0)
    800006d8:	4605                	li	a2,1
    800006da:	45a9                	li	a1,10
    800006dc:	4388                	lw	a0,0(a5)
    800006de:	00000097          	auipc	ra,0x0
    800006e2:	dfa080e7          	jalr	-518(ra) # 800004d8 <printint>
      break;
    800006e6:	b769                	j	80000670 <printf+0x98>
      printptr(va_arg(ap, uint64));
    800006e8:	f8843783          	ld	a5,-120(s0)
    800006ec:	00878713          	addi	a4,a5,8
    800006f0:	f8e43423          	sd	a4,-120(s0)
    800006f4:	0007b983          	ld	s3,0(a5)
  consputc('0');
    800006f8:	03000513          	li	a0,48
    800006fc:	00000097          	auipc	ra,0x0
    80000700:	b02080e7          	jalr	-1278(ra) # 800001fe <consputc>
  consputc('x');
    80000704:	07800513          	li	a0,120
    80000708:	00000097          	auipc	ra,0x0
    8000070c:	af6080e7          	jalr	-1290(ra) # 800001fe <consputc>
    80000710:	896a                	mv	s2,s10
    consputc(digits[x >> (sizeof(uint64) * 8 - 4)]);
    80000712:	03c9d793          	srli	a5,s3,0x3c
    80000716:	97de                	add	a5,a5,s7
    80000718:	0007c503          	lbu	a0,0(a5)
    8000071c:	00000097          	auipc	ra,0x0
    80000720:	ae2080e7          	jalr	-1310(ra) # 800001fe <consputc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
    80000724:	0992                	slli	s3,s3,0x4
    80000726:	397d                	addiw	s2,s2,-1
    80000728:	fe0915e3          	bnez	s2,80000712 <printf+0x13a>
    8000072c:	b791                	j	80000670 <printf+0x98>
      if((s = va_arg(ap, char*)) == 0)
    8000072e:	f8843783          	ld	a5,-120(s0)
    80000732:	00878713          	addi	a4,a5,8
    80000736:	f8e43423          	sd	a4,-120(s0)
    8000073a:	0007b903          	ld	s2,0(a5)
    8000073e:	00090e63          	beqz	s2,8000075a <printf+0x182>
      for(; *s; s++)
    80000742:	00094503          	lbu	a0,0(s2)
    80000746:	d50d                	beqz	a0,80000670 <printf+0x98>
        consputc(*s);
    80000748:	00000097          	auipc	ra,0x0
    8000074c:	ab6080e7          	jalr	-1354(ra) # 800001fe <consputc>
      for(; *s; s++)
    80000750:	0905                	addi	s2,s2,1
    80000752:	00094503          	lbu	a0,0(s2)
    80000756:	f96d                	bnez	a0,80000748 <printf+0x170>
    80000758:	bf21                	j	80000670 <printf+0x98>
        s = "(null)";
    8000075a:	00008917          	auipc	s2,0x8
    8000075e:	a9e90913          	addi	s2,s2,-1378 # 800081f8 <userret+0x168>
      for(; *s; s++)
    80000762:	02800513          	li	a0,40
    80000766:	b7cd                	j	80000748 <printf+0x170>
      consputc('%');
    80000768:	8552                	mv	a0,s4
    8000076a:	00000097          	auipc	ra,0x0
    8000076e:	a94080e7          	jalr	-1388(ra) # 800001fe <consputc>
      break;
    80000772:	bdfd                	j	80000670 <printf+0x98>
      consputc('%');
    80000774:	8552                	mv	a0,s4
    80000776:	00000097          	auipc	ra,0x0
    8000077a:	a88080e7          	jalr	-1400(ra) # 800001fe <consputc>
      consputc(c);
    8000077e:	854a                	mv	a0,s2
    80000780:	00000097          	auipc	ra,0x0
    80000784:	a7e080e7          	jalr	-1410(ra) # 800001fe <consputc>
      break;
    80000788:	b5e5                	j	80000670 <printf+0x98>
  if(locking)
    8000078a:	020d9163          	bnez	s11,800007ac <printf+0x1d4>
}
    8000078e:	70e6                	ld	ra,120(sp)
    80000790:	7446                	ld	s0,112(sp)
    80000792:	74a6                	ld	s1,104(sp)
    80000794:	7906                	ld	s2,96(sp)
    80000796:	69e6                	ld	s3,88(sp)
    80000798:	6a46                	ld	s4,80(sp)
    8000079a:	6aa6                	ld	s5,72(sp)
    8000079c:	6b06                	ld	s6,64(sp)
    8000079e:	7be2                	ld	s7,56(sp)
    800007a0:	7c42                	ld	s8,48(sp)
    800007a2:	7ca2                	ld	s9,40(sp)
    800007a4:	7d02                	ld	s10,32(sp)
    800007a6:	6de2                	ld	s11,24(sp)
    800007a8:	6129                	addi	sp,sp,192
    800007aa:	8082                	ret
    release(&pr.lock);
    800007ac:	00012517          	auipc	a0,0x12
    800007b0:	10450513          	addi	a0,a0,260 # 800128b0 <pr>
    800007b4:	00000097          	auipc	ra,0x0
    800007b8:	502080e7          	jalr	1282(ra) # 80000cb6 <release>
}
    800007bc:	bfc9                	j	8000078e <printf+0x1b6>

00000000800007be <printfinit>:
    ;
}

void
printfinit(void)
{
    800007be:	1101                	addi	sp,sp,-32
    800007c0:	ec06                	sd	ra,24(sp)
    800007c2:	e822                	sd	s0,16(sp)
    800007c4:	e426                	sd	s1,8(sp)
    800007c6:	1000                	addi	s0,sp,32
  initlock(&pr.lock, "pr");
    800007c8:	00012497          	auipc	s1,0x12
    800007cc:	0e848493          	addi	s1,s1,232 # 800128b0 <pr>
    800007d0:	00008597          	auipc	a1,0x8
    800007d4:	a4058593          	addi	a1,a1,-1472 # 80008210 <userret+0x180>
    800007d8:	8526                	mv	a0,s1
    800007da:	00000097          	auipc	ra,0x0
    800007de:	31c080e7          	jalr	796(ra) # 80000af6 <initlock>
  pr.locking = 1;
    800007e2:	4785                	li	a5,1
    800007e4:	d09c                	sw	a5,32(s1)
}
    800007e6:	60e2                	ld	ra,24(sp)
    800007e8:	6442                	ld	s0,16(sp)
    800007ea:	64a2                	ld	s1,8(sp)
    800007ec:	6105                	addi	sp,sp,32
    800007ee:	8082                	ret

00000000800007f0 <uartinit>:
#define ReadReg(reg) (*(Reg(reg)))
#define WriteReg(reg, v) (*(Reg(reg)) = (v))

void
uartinit(void)
{
    800007f0:	1141                	addi	sp,sp,-16
    800007f2:	e422                	sd	s0,8(sp)
    800007f4:	0800                	addi	s0,sp,16
  // disable interrupts.
  WriteReg(IER, 0x00);
    800007f6:	100007b7          	lui	a5,0x10000
    800007fa:	000780a3          	sb	zero,1(a5) # 10000001 <_entry-0x6fffffff>

  // special mode to set baud rate.
  WriteReg(LCR, 0x80);
    800007fe:	f8000713          	li	a4,-128
    80000802:	00e781a3          	sb	a4,3(a5)

  // LSB for baud rate of 38.4K.
  WriteReg(0, 0x03);
    80000806:	470d                	li	a4,3
    80000808:	00e78023          	sb	a4,0(a5)

  // MSB for baud rate of 38.4K.
  WriteReg(1, 0x00);
    8000080c:	000780a3          	sb	zero,1(a5)

  // leave set-baud mode,
  // and set word length to 8 bits, no parity.
  WriteReg(LCR, 0x03);
    80000810:	00e781a3          	sb	a4,3(a5)

  // reset and enable FIFOs.
  WriteReg(FCR, 0x07);
    80000814:	471d                	li	a4,7
    80000816:	00e78123          	sb	a4,2(a5)

  // enable receive interrupts.
  WriteReg(IER, 0x01);
    8000081a:	4705                	li	a4,1
    8000081c:	00e780a3          	sb	a4,1(a5)
}
    80000820:	6422                	ld	s0,8(sp)
    80000822:	0141                	addi	sp,sp,16
    80000824:	8082                	ret

0000000080000826 <uartputc>:

// write one output character to the UART.
void
uartputc(int c)
{
    80000826:	1141                	addi	sp,sp,-16
    80000828:	e422                	sd	s0,8(sp)
    8000082a:	0800                	addi	s0,sp,16
  // wait for Transmit Holding Empty to be set in LSR.
  while((ReadReg(LSR) & (1 << 5)) == 0)
    8000082c:	10000737          	lui	a4,0x10000
    80000830:	00574783          	lbu	a5,5(a4) # 10000005 <_entry-0x6ffffffb>
    80000834:	0ff7f793          	andi	a5,a5,255
    80000838:	0207f793          	andi	a5,a5,32
    8000083c:	dbf5                	beqz	a5,80000830 <uartputc+0xa>
    ;
  WriteReg(THR, c);
    8000083e:	0ff57513          	andi	a0,a0,255
    80000842:	100007b7          	lui	a5,0x10000
    80000846:	00a78023          	sb	a0,0(a5) # 10000000 <_entry-0x70000000>
}
    8000084a:	6422                	ld	s0,8(sp)
    8000084c:	0141                	addi	sp,sp,16
    8000084e:	8082                	ret

0000000080000850 <uartgetc>:

// read one input character from the UART.
// return -1 if none is waiting.
int
uartgetc(void)
{
    80000850:	1141                	addi	sp,sp,-16
    80000852:	e422                	sd	s0,8(sp)
    80000854:	0800                	addi	s0,sp,16
  if(ReadReg(LSR) & 0x01){
    80000856:	100007b7          	lui	a5,0x10000
    8000085a:	0057c783          	lbu	a5,5(a5) # 10000005 <_entry-0x6ffffffb>
    8000085e:	8b85                	andi	a5,a5,1
    80000860:	cb91                	beqz	a5,80000874 <uartgetc+0x24>
    // input data is ready.
    return ReadReg(RHR);
    80000862:	100007b7          	lui	a5,0x10000
    80000866:	0007c503          	lbu	a0,0(a5) # 10000000 <_entry-0x70000000>
    8000086a:	0ff57513          	andi	a0,a0,255
  } else {
    return -1;
  }
}
    8000086e:	6422                	ld	s0,8(sp)
    80000870:	0141                	addi	sp,sp,16
    80000872:	8082                	ret
    return -1;
    80000874:	557d                	li	a0,-1
    80000876:	bfe5                	j	8000086e <uartgetc+0x1e>

0000000080000878 <uartintr>:

// trap.c calls here when the uart interrupts.
void
uartintr(void)
{
    80000878:	1101                	addi	sp,sp,-32
    8000087a:	ec06                	sd	ra,24(sp)
    8000087c:	e822                	sd	s0,16(sp)
    8000087e:	e426                	sd	s1,8(sp)
    80000880:	1000                	addi	s0,sp,32
  while(1){
    int c = uartgetc();
    if(c == -1)
    80000882:	54fd                	li	s1,-1
    int c = uartgetc();
    80000884:	00000097          	auipc	ra,0x0
    80000888:	fcc080e7          	jalr	-52(ra) # 80000850 <uartgetc>
    if(c == -1)
    8000088c:	00950763          	beq	a0,s1,8000089a <uartintr+0x22>
      break;
    consoleintr(c);
    80000890:	00000097          	auipc	ra,0x0
    80000894:	a48080e7          	jalr	-1464(ra) # 800002d8 <consoleintr>
  while(1){
    80000898:	b7f5                	j	80000884 <uartintr+0xc>
  }
}
    8000089a:	60e2                	ld	ra,24(sp)
    8000089c:	6442                	ld	s0,16(sp)
    8000089e:	64a2                	ld	s1,8(sp)
    800008a0:	6105                	addi	sp,sp,32
    800008a2:	8082                	ret

00000000800008a4 <kfree>:
// which normally should have been returned by a
// call to kalloc().  (The exception is when
// initializing the allocator; see kinit above.)
void
kfree(void *pa)
{
    800008a4:	7139                	addi	sp,sp,-64
    800008a6:	fc06                	sd	ra,56(sp)
    800008a8:	f822                	sd	s0,48(sp)
    800008aa:	f426                	sd	s1,40(sp)
    800008ac:	f04a                	sd	s2,32(sp)
    800008ae:	ec4e                	sd	s3,24(sp)
    800008b0:	e852                	sd	s4,16(sp)
    800008b2:	e456                	sd	s5,8(sp)
    800008b4:	0080                	addi	s0,sp,64
  struct run *r;

  if(((uint64)pa % PGSIZE) != 0 || (char*)pa < end || (uint64)pa >= PHYSTOP)
    800008b6:	6785                	lui	a5,0x1
    800008b8:	17fd                	addi	a5,a5,-1
    800008ba:	8fe9                	and	a5,a5,a0
    800008bc:	e3c1                	bnez	a5,8000093c <kfree+0x98>
    800008be:	892a                	mv	s2,a0
    800008c0:	0002f797          	auipc	a5,0x2f
    800008c4:	79c78793          	addi	a5,a5,1948 # 8003005c <end>
    800008c8:	06f56a63          	bltu	a0,a5,8000093c <kfree+0x98>
    800008cc:	47c5                	li	a5,17
    800008ce:	07ee                	slli	a5,a5,0x1b
    800008d0:	06f57663          	bleu	a5,a0,8000093c <kfree+0x98>
    panic("kfree");

  // Fill with junk to catch dangling refs.
  memset(pa, 1, PGSIZE);
    800008d4:	6605                	lui	a2,0x1
    800008d6:	4585                	li	a1,1
    800008d8:	00000097          	auipc	ra,0x0
    800008dc:	604080e7          	jalr	1540(ra) # 80000edc <memset>

  r = (struct run*)pa;

  push_off();
    800008e0:	00000097          	auipc	ra,0x0
    800008e4:	26e080e7          	jalr	622(ra) # 80000b4e <push_off>
  int cid = cpuid();
    800008e8:	00001097          	auipc	ra,0x1
    800008ec:	2f2080e7          	jalr	754(ra) # 80001bda <cpuid>
  acquire(&kmem[cid].lock);
    800008f0:	00012a17          	auipc	s4,0x12
    800008f4:	fe8a0a13          	addi	s4,s4,-24 # 800128d8 <kmem>
    800008f8:	00251993          	slli	s3,a0,0x2
    800008fc:	00a984b3          	add	s1,s3,a0
    80000900:	048e                	slli	s1,s1,0x3
    80000902:	94d2                	add	s1,s1,s4
    80000904:	8526                	mv	a0,s1
    80000906:	00000097          	auipc	ra,0x0
    8000090a:	340080e7          	jalr	832(ra) # 80000c46 <acquire>
  r->next = kmem[cid].freelist;
    8000090e:	709c                	ld	a5,32(s1)
    80000910:	00f93023          	sd	a5,0(s2)
  kmem[cid].freelist = r;
    80000914:	0324b023          	sd	s2,32(s1)
  release(&kmem[cid].lock);
    80000918:	8526                	mv	a0,s1
    8000091a:	00000097          	auipc	ra,0x0
    8000091e:	39c080e7          	jalr	924(ra) # 80000cb6 <release>
  pop_off();
    80000922:	00000097          	auipc	ra,0x0
    80000926:	278080e7          	jalr	632(ra) # 80000b9a <pop_off>
}
    8000092a:	70e2                	ld	ra,56(sp)
    8000092c:	7442                	ld	s0,48(sp)
    8000092e:	74a2                	ld	s1,40(sp)
    80000930:	7902                	ld	s2,32(sp)
    80000932:	69e2                	ld	s3,24(sp)
    80000934:	6a42                	ld	s4,16(sp)
    80000936:	6aa2                	ld	s5,8(sp)
    80000938:	6121                	addi	sp,sp,64
    8000093a:	8082                	ret
    panic("kfree");
    8000093c:	00008517          	auipc	a0,0x8
    80000940:	8dc50513          	addi	a0,a0,-1828 # 80008218 <userret+0x188>
    80000944:	00000097          	auipc	ra,0x0
    80000948:	c3a080e7          	jalr	-966(ra) # 8000057e <panic>

000000008000094c <freerange>:
{
    8000094c:	7179                	addi	sp,sp,-48
    8000094e:	f406                	sd	ra,40(sp)
    80000950:	f022                	sd	s0,32(sp)
    80000952:	ec26                	sd	s1,24(sp)
    80000954:	e84a                	sd	s2,16(sp)
    80000956:	e44e                	sd	s3,8(sp)
    80000958:	e052                	sd	s4,0(sp)
    8000095a:	1800                	addi	s0,sp,48
  p = (char*)PGROUNDUP((uint64)pa_start);
    8000095c:	6705                	lui	a4,0x1
    8000095e:	fff70793          	addi	a5,a4,-1 # fff <_entry-0x7ffff001>
    80000962:	00f504b3          	add	s1,a0,a5
    80000966:	77fd                	lui	a5,0xfffff
    80000968:	8cfd                	and	s1,s1,a5
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    8000096a:	94ba                	add	s1,s1,a4
    8000096c:	0095ee63          	bltu	a1,s1,80000988 <freerange+0x3c>
    80000970:	892e                	mv	s2,a1
    kfree(p);
    80000972:	7a7d                	lui	s4,0xfffff
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000974:	6985                	lui	s3,0x1
    kfree(p);
    80000976:	01448533          	add	a0,s1,s4
    8000097a:	00000097          	auipc	ra,0x0
    8000097e:	f2a080e7          	jalr	-214(ra) # 800008a4 <kfree>
  for(; p + PGSIZE <= (char*)pa_end; p += PGSIZE)
    80000982:	94ce                	add	s1,s1,s3
    80000984:	fe9979e3          	bleu	s1,s2,80000976 <freerange+0x2a>
}
    80000988:	70a2                	ld	ra,40(sp)
    8000098a:	7402                	ld	s0,32(sp)
    8000098c:	64e2                	ld	s1,24(sp)
    8000098e:	6942                	ld	s2,16(sp)
    80000990:	69a2                	ld	s3,8(sp)
    80000992:	6a02                	ld	s4,0(sp)
    80000994:	6145                	addi	sp,sp,48
    80000996:	8082                	ret

0000000080000998 <kinit>:
{
    80000998:	7179                	addi	sp,sp,-48
    8000099a:	f406                	sd	ra,40(sp)
    8000099c:	f022                	sd	s0,32(sp)
    8000099e:	ec26                	sd	s1,24(sp)
    800009a0:	e84a                	sd	s2,16(sp)
    800009a2:	e44e                	sd	s3,8(sp)
    800009a4:	1800                	addi	s0,sp,48
  for (int i = 0; i < NCPU; i++) {
    800009a6:	00012497          	auipc	s1,0x12
    800009aa:	f3248493          	addi	s1,s1,-206 # 800128d8 <kmem>
    800009ae:	00012997          	auipc	s3,0x12
    800009b2:	06a98993          	addi	s3,s3,106 # 80012a18 <locks>
    initlock(&kmem[i].lock, "kmem");
    800009b6:	00008917          	auipc	s2,0x8
    800009ba:	86a90913          	addi	s2,s2,-1942 # 80008220 <userret+0x190>
    800009be:	85ca                	mv	a1,s2
    800009c0:	8526                	mv	a0,s1
    800009c2:	00000097          	auipc	ra,0x0
    800009c6:	134080e7          	jalr	308(ra) # 80000af6 <initlock>
  for (int i = 0; i < NCPU; i++) {
    800009ca:	02848493          	addi	s1,s1,40
    800009ce:	ff3498e3          	bne	s1,s3,800009be <kinit+0x26>
  freerange(end, (void*)PHYSTOP);
    800009d2:	45c5                	li	a1,17
    800009d4:	05ee                	slli	a1,a1,0x1b
    800009d6:	0002f517          	auipc	a0,0x2f
    800009da:	68650513          	addi	a0,a0,1670 # 8003005c <end>
    800009de:	00000097          	auipc	ra,0x0
    800009e2:	f6e080e7          	jalr	-146(ra) # 8000094c <freerange>
}
    800009e6:	70a2                	ld	ra,40(sp)
    800009e8:	7402                	ld	s0,32(sp)
    800009ea:	64e2                	ld	s1,24(sp)
    800009ec:	6942                	ld	s2,16(sp)
    800009ee:	69a2                	ld	s3,8(sp)
    800009f0:	6145                	addi	sp,sp,48
    800009f2:	8082                	ret

00000000800009f4 <kalloc>:
// Allocate one 4096-byte page of physical memory.
// Returns a pointer that the kernel can use.
// Returns 0 if the memory cannot be allocated.
void *
kalloc(void)
{
    800009f4:	715d                	addi	sp,sp,-80
    800009f6:	e486                	sd	ra,72(sp)
    800009f8:	e0a2                	sd	s0,64(sp)
    800009fa:	fc26                	sd	s1,56(sp)
    800009fc:	f84a                	sd	s2,48(sp)
    800009fe:	f44e                	sd	s3,40(sp)
    80000a00:	f052                	sd	s4,32(sp)
    80000a02:	ec56                	sd	s5,24(sp)
    80000a04:	e85a                	sd	s6,16(sp)
    80000a06:	e45e                	sd	s7,8(sp)
    80000a08:	0880                	addi	s0,sp,80
  struct run *r;

  push_off();
    80000a0a:	00000097          	auipc	ra,0x0
    80000a0e:	144080e7          	jalr	324(ra) # 80000b4e <push_off>
  int cid = cpuid();
    80000a12:	00001097          	auipc	ra,0x1
    80000a16:	1c8080e7          	jalr	456(ra) # 80001bda <cpuid>
    80000a1a:	89aa                	mv	s3,a0
  acquire(&kmem[cid].lock);
    80000a1c:	00251493          	slli	s1,a0,0x2
    80000a20:	94aa                	add	s1,s1,a0
    80000a22:	00349793          	slli	a5,s1,0x3
    80000a26:	00012497          	auipc	s1,0x12
    80000a2a:	eb248493          	addi	s1,s1,-334 # 800128d8 <kmem>
    80000a2e:	94be                	add	s1,s1,a5
    80000a30:	8526                	mv	a0,s1
    80000a32:	00000097          	auipc	ra,0x0
    80000a36:	214080e7          	jalr	532(ra) # 80000c46 <acquire>
  r = kmem[cid].freelist;
    80000a3a:	0204ba03          	ld	s4,32(s1)
  if(r) {
    80000a3e:	040a0163          	beqz	s4,80000a80 <kalloc+0x8c>
    kmem[cid].freelist = r->next;
    80000a42:	000a3703          	ld	a4,0(s4) # fffffffffffff000 <end+0xffffffff7ffcefa4>
    80000a46:	f098                	sd	a4,32(s1)
    release(&kmem[cid].lock);
    80000a48:	8526                	mv	a0,s1
    80000a4a:	00000097          	auipc	ra,0x0
    80000a4e:	26c080e7          	jalr	620(ra) # 80000cb6 <release>
        break;
      }
      release(&kmem[i].lock);
    }
  }
  pop_off();
    80000a52:	00000097          	auipc	ra,0x0
    80000a56:	148080e7          	jalr	328(ra) # 80000b9a <pop_off>


  if(r)
    memset((char*)r, 5, PGSIZE); // fill with junk
    80000a5a:	6605                	lui	a2,0x1
    80000a5c:	4595                	li	a1,5
    80000a5e:	8552                	mv	a0,s4
    80000a60:	00000097          	auipc	ra,0x0
    80000a64:	47c080e7          	jalr	1148(ra) # 80000edc <memset>
  return (void*)r;
}
    80000a68:	8552                	mv	a0,s4
    80000a6a:	60a6                	ld	ra,72(sp)
    80000a6c:	6406                	ld	s0,64(sp)
    80000a6e:	74e2                	ld	s1,56(sp)
    80000a70:	7942                	ld	s2,48(sp)
    80000a72:	79a2                	ld	s3,40(sp)
    80000a74:	7a02                	ld	s4,32(sp)
    80000a76:	6ae2                	ld	s5,24(sp)
    80000a78:	6b42                	ld	s6,16(sp)
    80000a7a:	6ba2                	ld	s7,8(sp)
    80000a7c:	6161                	addi	sp,sp,80
    80000a7e:	8082                	ret
    release(&kmem[cid].lock);
    80000a80:	8526                	mv	a0,s1
    80000a82:	00000097          	auipc	ra,0x0
    80000a86:	234080e7          	jalr	564(ra) # 80000cb6 <release>
    for (int i = 0; i < NCPU; i++) {
    80000a8a:	00012497          	auipc	s1,0x12
    80000a8e:	e4e48493          	addi	s1,s1,-434 # 800128d8 <kmem>
    80000a92:	4901                	li	s2,0
    80000a94:	4b21                	li	s6,8
    80000a96:	a815                	j	80000aca <kalloc+0xd6>
        kmem[i].freelist = r->next;
    80000a98:	000ab703          	ld	a4,0(s5)
    80000a9c:	00291793          	slli	a5,s2,0x2
    80000aa0:	993e                	add	s2,s2,a5
    80000aa2:	090e                	slli	s2,s2,0x3
    80000aa4:	00012797          	auipc	a5,0x12
    80000aa8:	e3478793          	addi	a5,a5,-460 # 800128d8 <kmem>
    80000aac:	993e                	add	s2,s2,a5
    80000aae:	02e93023          	sd	a4,32(s2)
        release(&kmem[i].lock);
    80000ab2:	8526                	mv	a0,s1
    80000ab4:	00000097          	auipc	ra,0x0
    80000ab8:	202080e7          	jalr	514(ra) # 80000cb6 <release>
      r = kmem[i].freelist;
    80000abc:	8a56                	mv	s4,s5
        break;
    80000abe:	bf51                	j	80000a52 <kalloc+0x5e>
    for (int i = 0; i < NCPU; i++) {
    80000ac0:	2905                	addiw	s2,s2,1
    80000ac2:	02848493          	addi	s1,s1,40
    80000ac6:	03690363          	beq	s2,s6,80000aec <kalloc+0xf8>
      if (i == cid) continue;
    80000aca:	ff298be3          	beq	s3,s2,80000ac0 <kalloc+0xcc>
      acquire(&kmem[i].lock);
    80000ace:	8526                	mv	a0,s1
    80000ad0:	00000097          	auipc	ra,0x0
    80000ad4:	176080e7          	jalr	374(ra) # 80000c46 <acquire>
      r = kmem[i].freelist;
    80000ad8:	0204ba83          	ld	s5,32(s1)
      if (r) {
    80000adc:	fa0a9ee3          	bnez	s5,80000a98 <kalloc+0xa4>
      release(&kmem[i].lock);
    80000ae0:	8526                	mv	a0,s1
    80000ae2:	00000097          	auipc	ra,0x0
    80000ae6:	1d4080e7          	jalr	468(ra) # 80000cb6 <release>
    80000aea:	bfd9                	j	80000ac0 <kalloc+0xcc>
  pop_off();
    80000aec:	00000097          	auipc	ra,0x0
    80000af0:	0ae080e7          	jalr	174(ra) # 80000b9a <pop_off>
  return (void*)r;
    80000af4:	bf95                	j	80000a68 <kalloc+0x74>

0000000080000af6 <initlock>:

// assumes locks are not freed
void
initlock(struct spinlock *lk, char *name)
{
  lk->name = name;
    80000af6:	e50c                	sd	a1,8(a0)
  lk->locked = 0;
    80000af8:	00052023          	sw	zero,0(a0)
  lk->cpu = 0;
    80000afc:	00053823          	sd	zero,16(a0)
  lk->nts = 0;
    80000b00:	00052e23          	sw	zero,28(a0)
  lk->n = 0;
    80000b04:	00052c23          	sw	zero,24(a0)
  if(nlock >= NLOCK)
    80000b08:	0002f797          	auipc	a5,0x2f
    80000b0c:	51c78793          	addi	a5,a5,1308 # 80030024 <nlock>
    80000b10:	439c                	lw	a5,0(a5)
    80000b12:	3e700713          	li	a4,999
    80000b16:	02f74063          	blt	a4,a5,80000b36 <initlock+0x40>
    panic("initlock");
  locks[nlock] = lk;
    80000b1a:	00379693          	slli	a3,a5,0x3
    80000b1e:	00012717          	auipc	a4,0x12
    80000b22:	efa70713          	addi	a4,a4,-262 # 80012a18 <locks>
    80000b26:	9736                	add	a4,a4,a3
    80000b28:	e308                	sd	a0,0(a4)
  nlock++;
    80000b2a:	2785                	addiw	a5,a5,1
    80000b2c:	0002f717          	auipc	a4,0x2f
    80000b30:	4ef72c23          	sw	a5,1272(a4) # 80030024 <nlock>
    80000b34:	8082                	ret
{
    80000b36:	1141                	addi	sp,sp,-16
    80000b38:	e406                	sd	ra,8(sp)
    80000b3a:	e022                	sd	s0,0(sp)
    80000b3c:	0800                	addi	s0,sp,16
    panic("initlock");
    80000b3e:	00007517          	auipc	a0,0x7
    80000b42:	6ea50513          	addi	a0,a0,1770 # 80008228 <userret+0x198>
    80000b46:	00000097          	auipc	ra,0x0
    80000b4a:	a38080e7          	jalr	-1480(ra) # 8000057e <panic>

0000000080000b4e <push_off>:
// it takes two pop_off()s to undo two push_off()s.  Also, if interrupts
// are initially off, then push_off, pop_off leaves them off.

void
push_off(void)
{
    80000b4e:	1101                	addi	sp,sp,-32
    80000b50:	ec06                	sd	ra,24(sp)
    80000b52:	e822                	sd	s0,16(sp)
    80000b54:	e426                	sd	s1,8(sp)
    80000b56:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000b58:	100024f3          	csrr	s1,sstatus
    80000b5c:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() & ~SSTATUS_SIE);
    80000b60:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80000b62:	10079073          	csrw	sstatus,a5
  int old = intr_get();

  intr_off();
  if(mycpu()->noff == 0)
    80000b66:	00001097          	auipc	ra,0x1
    80000b6a:	084080e7          	jalr	132(ra) # 80001bea <mycpu>
    80000b6e:	5d3c                	lw	a5,120(a0)
    80000b70:	cf89                	beqz	a5,80000b8a <push_off+0x3c>
    mycpu()->intena = old;
  mycpu()->noff += 1;
    80000b72:	00001097          	auipc	ra,0x1
    80000b76:	078080e7          	jalr	120(ra) # 80001bea <mycpu>
    80000b7a:	5d3c                	lw	a5,120(a0)
    80000b7c:	2785                	addiw	a5,a5,1
    80000b7e:	dd3c                	sw	a5,120(a0)
}
    80000b80:	60e2                	ld	ra,24(sp)
    80000b82:	6442                	ld	s0,16(sp)
    80000b84:	64a2                	ld	s1,8(sp)
    80000b86:	6105                	addi	sp,sp,32
    80000b88:	8082                	ret
    mycpu()->intena = old;
    80000b8a:	00001097          	auipc	ra,0x1
    80000b8e:	060080e7          	jalr	96(ra) # 80001bea <mycpu>
  return (x & SSTATUS_SIE) != 0;
    80000b92:	8085                	srli	s1,s1,0x1
    80000b94:	8885                	andi	s1,s1,1
    80000b96:	dd64                	sw	s1,124(a0)
    80000b98:	bfe9                	j	80000b72 <push_off+0x24>

0000000080000b9a <pop_off>:

void
pop_off(void)
{
    80000b9a:	1141                	addi	sp,sp,-16
    80000b9c:	e406                	sd	ra,8(sp)
    80000b9e:	e022                	sd	s0,0(sp)
    80000ba0:	0800                	addi	s0,sp,16
  struct cpu *c = mycpu();
    80000ba2:	00001097          	auipc	ra,0x1
    80000ba6:	048080e7          	jalr	72(ra) # 80001bea <mycpu>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000baa:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80000bae:	8b89                	andi	a5,a5,2
  if(intr_get())
    80000bb0:	eb9d                	bnez	a5,80000be6 <pop_off+0x4c>
    panic("pop_off - interruptible");
  c->noff -= 1;
    80000bb2:	5d3c                	lw	a5,120(a0)
    80000bb4:	37fd                	addiw	a5,a5,-1
    80000bb6:	0007871b          	sext.w	a4,a5
    80000bba:	dd3c                	sw	a5,120(a0)
  if(c->noff < 0)
    80000bbc:	02074d63          	bltz	a4,80000bf6 <pop_off+0x5c>
    panic("pop_off");
  if(c->noff == 0 && c->intena)
    80000bc0:	ef19                	bnez	a4,80000bde <pop_off+0x44>
    80000bc2:	5d7c                	lw	a5,124(a0)
    80000bc4:	cf89                	beqz	a5,80000bde <pop_off+0x44>
  asm volatile("csrr %0, sie" : "=r" (x) );
    80000bc6:	104027f3          	csrr	a5,sie
  w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
    80000bca:	2227e793          	ori	a5,a5,546
  asm volatile("csrw sie, %0" : : "r" (x));
    80000bce:	10479073          	csrw	sie,a5
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80000bd2:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80000bd6:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80000bda:	10079073          	csrw	sstatus,a5
    intr_on();
}
    80000bde:	60a2                	ld	ra,8(sp)
    80000be0:	6402                	ld	s0,0(sp)
    80000be2:	0141                	addi	sp,sp,16
    80000be4:	8082                	ret
    panic("pop_off - interruptible");
    80000be6:	00007517          	auipc	a0,0x7
    80000bea:	65250513          	addi	a0,a0,1618 # 80008238 <userret+0x1a8>
    80000bee:	00000097          	auipc	ra,0x0
    80000bf2:	990080e7          	jalr	-1648(ra) # 8000057e <panic>
    panic("pop_off");
    80000bf6:	00007517          	auipc	a0,0x7
    80000bfa:	65a50513          	addi	a0,a0,1626 # 80008250 <userret+0x1c0>
    80000bfe:	00000097          	auipc	ra,0x0
    80000c02:	980080e7          	jalr	-1664(ra) # 8000057e <panic>

0000000080000c06 <holding>:
{
    80000c06:	1101                	addi	sp,sp,-32
    80000c08:	ec06                	sd	ra,24(sp)
    80000c0a:	e822                	sd	s0,16(sp)
    80000c0c:	e426                	sd	s1,8(sp)
    80000c0e:	1000                	addi	s0,sp,32
    80000c10:	84aa                	mv	s1,a0
  push_off();
    80000c12:	00000097          	auipc	ra,0x0
    80000c16:	f3c080e7          	jalr	-196(ra) # 80000b4e <push_off>
  r = (lk->locked && lk->cpu == mycpu());
    80000c1a:	409c                	lw	a5,0(s1)
    80000c1c:	ef81                	bnez	a5,80000c34 <holding+0x2e>
    80000c1e:	4481                	li	s1,0
  pop_off();
    80000c20:	00000097          	auipc	ra,0x0
    80000c24:	f7a080e7          	jalr	-134(ra) # 80000b9a <pop_off>
}
    80000c28:	8526                	mv	a0,s1
    80000c2a:	60e2                	ld	ra,24(sp)
    80000c2c:	6442                	ld	s0,16(sp)
    80000c2e:	64a2                	ld	s1,8(sp)
    80000c30:	6105                	addi	sp,sp,32
    80000c32:	8082                	ret
  r = (lk->locked && lk->cpu == mycpu());
    80000c34:	6884                	ld	s1,16(s1)
    80000c36:	00001097          	auipc	ra,0x1
    80000c3a:	fb4080e7          	jalr	-76(ra) # 80001bea <mycpu>
    80000c3e:	8c89                	sub	s1,s1,a0
    80000c40:	0014b493          	seqz	s1,s1
    80000c44:	bff1                	j	80000c20 <holding+0x1a>

0000000080000c46 <acquire>:
{
    80000c46:	1101                	addi	sp,sp,-32
    80000c48:	ec06                	sd	ra,24(sp)
    80000c4a:	e822                	sd	s0,16(sp)
    80000c4c:	e426                	sd	s1,8(sp)
    80000c4e:	1000                	addi	s0,sp,32
    80000c50:	84aa                	mv	s1,a0
  push_off(); // disable interrupts to avoid deadlock.
    80000c52:	00000097          	auipc	ra,0x0
    80000c56:	efc080e7          	jalr	-260(ra) # 80000b4e <push_off>
  if(holding(lk))
    80000c5a:	8526                	mv	a0,s1
    80000c5c:	00000097          	auipc	ra,0x0
    80000c60:	faa080e7          	jalr	-86(ra) # 80000c06 <holding>
    80000c64:	e50d                	bnez	a0,80000c8e <acquire+0x48>
  __sync_fetch_and_add(&(lk->n), 1);
    80000c66:	4785                	li	a5,1
    80000c68:	01848713          	addi	a4,s1,24
    80000c6c:	0f50000f          	fence	iorw,ow
    80000c70:	04f7202f          	amoadd.w.aq	zero,a5,(a4)
  while(__sync_lock_test_and_set(&lk->locked, 1) != 0) {
    80000c74:	4705                	li	a4,1
    80000c76:	87ba                	mv	a5,a4
    80000c78:	0cf4a7af          	amoswap.w.aq	a5,a5,(s1)
    80000c7c:	2781                	sext.w	a5,a5
    80000c7e:	c385                	beqz	a5,80000c9e <acquire+0x58>
     __sync_fetch_and_add(&lk->nts, 1);
    80000c80:	01c48793          	addi	a5,s1,28
    80000c84:	0f50000f          	fence	iorw,ow
    80000c88:	04e7a02f          	amoadd.w.aq	zero,a4,(a5)
    80000c8c:	b7ed                	j	80000c76 <acquire+0x30>
    panic("acquire");
    80000c8e:	00007517          	auipc	a0,0x7
    80000c92:	5ca50513          	addi	a0,a0,1482 # 80008258 <userret+0x1c8>
    80000c96:	00000097          	auipc	ra,0x0
    80000c9a:	8e8080e7          	jalr	-1816(ra) # 8000057e <panic>
  __sync_synchronize();
    80000c9e:	0ff0000f          	fence
  lk->cpu = mycpu();
    80000ca2:	00001097          	auipc	ra,0x1
    80000ca6:	f48080e7          	jalr	-184(ra) # 80001bea <mycpu>
    80000caa:	e888                	sd	a0,16(s1)
}
    80000cac:	60e2                	ld	ra,24(sp)
    80000cae:	6442                	ld	s0,16(sp)
    80000cb0:	64a2                	ld	s1,8(sp)
    80000cb2:	6105                	addi	sp,sp,32
    80000cb4:	8082                	ret

0000000080000cb6 <release>:
{
    80000cb6:	1101                	addi	sp,sp,-32
    80000cb8:	ec06                	sd	ra,24(sp)
    80000cba:	e822                	sd	s0,16(sp)
    80000cbc:	e426                	sd	s1,8(sp)
    80000cbe:	1000                	addi	s0,sp,32
    80000cc0:	84aa                	mv	s1,a0
  if(!holding(lk))
    80000cc2:	00000097          	auipc	ra,0x0
    80000cc6:	f44080e7          	jalr	-188(ra) # 80000c06 <holding>
    80000cca:	c115                	beqz	a0,80000cee <release+0x38>
  lk->cpu = 0;
    80000ccc:	0004b823          	sd	zero,16(s1)
  __sync_synchronize();
    80000cd0:	0ff0000f          	fence
  __sync_lock_release(&lk->locked);
    80000cd4:	0f50000f          	fence	iorw,ow
    80000cd8:	0804a02f          	amoswap.w	zero,zero,(s1)
  pop_off();
    80000cdc:	00000097          	auipc	ra,0x0
    80000ce0:	ebe080e7          	jalr	-322(ra) # 80000b9a <pop_off>
}
    80000ce4:	60e2                	ld	ra,24(sp)
    80000ce6:	6442                	ld	s0,16(sp)
    80000ce8:	64a2                	ld	s1,8(sp)
    80000cea:	6105                	addi	sp,sp,32
    80000cec:	8082                	ret
    panic("release");
    80000cee:	00007517          	auipc	a0,0x7
    80000cf2:	57250513          	addi	a0,a0,1394 # 80008260 <userret+0x1d0>
    80000cf6:	00000097          	auipc	ra,0x0
    80000cfa:	888080e7          	jalr	-1912(ra) # 8000057e <panic>

0000000080000cfe <print_lock>:

void
print_lock(struct spinlock *lk)
{
  if(lk->n > 0) 
    80000cfe:	4d14                	lw	a3,24(a0)
    80000d00:	e291                	bnez	a3,80000d04 <print_lock+0x6>
    80000d02:	8082                	ret
{
    80000d04:	1141                	addi	sp,sp,-16
    80000d06:	e406                	sd	ra,8(sp)
    80000d08:	e022                	sd	s0,0(sp)
    80000d0a:	0800                	addi	s0,sp,16
    printf("lock: %s: #test-and-set %d #acquire() %d\n", lk->name, lk->nts, lk->n);
    80000d0c:	4d50                	lw	a2,28(a0)
    80000d0e:	650c                	ld	a1,8(a0)
    80000d10:	00007517          	auipc	a0,0x7
    80000d14:	55850513          	addi	a0,a0,1368 # 80008268 <userret+0x1d8>
    80000d18:	00000097          	auipc	ra,0x0
    80000d1c:	8c0080e7          	jalr	-1856(ra) # 800005d8 <printf>
}
    80000d20:	60a2                	ld	ra,8(sp)
    80000d22:	6402                	ld	s0,0(sp)
    80000d24:	0141                	addi	sp,sp,16
    80000d26:	8082                	ret

0000000080000d28 <sys_ntas>:

uint64
sys_ntas(void)
{
    80000d28:	715d                	addi	sp,sp,-80
    80000d2a:	e486                	sd	ra,72(sp)
    80000d2c:	e0a2                	sd	s0,64(sp)
    80000d2e:	fc26                	sd	s1,56(sp)
    80000d30:	f84a                	sd	s2,48(sp)
    80000d32:	f44e                	sd	s3,40(sp)
    80000d34:	f052                	sd	s4,32(sp)
    80000d36:	ec56                	sd	s5,24(sp)
    80000d38:	e85a                	sd	s6,16(sp)
    80000d3a:	0880                	addi	s0,sp,80
  int zero = 0;
    80000d3c:	fa042e23          	sw	zero,-68(s0)
  int tot = 0;
  
  if (argint(0, &zero) < 0) {
    80000d40:	fbc40593          	addi	a1,s0,-68
    80000d44:	4501                	li	a0,0
    80000d46:	00002097          	auipc	ra,0x2
    80000d4a:	f4e080e7          	jalr	-178(ra) # 80002c94 <argint>
    80000d4e:	18054163          	bltz	a0,80000ed0 <sys_ntas+0x1a8>
    return -1;
  }
  if(zero == 0) {
    80000d52:	fbc42783          	lw	a5,-68(s0)
    80000d56:	e3a1                	bnez	a5,80000d96 <sys_ntas+0x6e>
    for(int i = 0; i < NLOCK; i++) {
      if(locks[i] == 0)
    80000d58:	00012797          	auipc	a5,0x12
    80000d5c:	cc078793          	addi	a5,a5,-832 # 80012a18 <locks>
    80000d60:	639c                	ld	a5,0(a5)
    80000d62:	16078963          	beqz	a5,80000ed4 <sys_ntas+0x1ac>
        break;
      locks[i]->nts = 0;
    80000d66:	0007ae23          	sw	zero,28(a5)
      locks[i]->n = 0;
    80000d6a:	0007ac23          	sw	zero,24(a5)
    for(int i = 0; i < NLOCK; i++) {
    80000d6e:	00012797          	auipc	a5,0x12
    80000d72:	cb278793          	addi	a5,a5,-846 # 80012a20 <locks+0x8>
    80000d76:	00014697          	auipc	a3,0x14
    80000d7a:	be268693          	addi	a3,a3,-1054 # 80014958 <pid_lock>
      if(locks[i] == 0)
    80000d7e:	6398                	ld	a4,0(a5)
    80000d80:	14070c63          	beqz	a4,80000ed8 <sys_ntas+0x1b0>
      locks[i]->nts = 0;
    80000d84:	00072e23          	sw	zero,28(a4)
      locks[i]->n = 0;
    80000d88:	00072c23          	sw	zero,24(a4)
    for(int i = 0; i < NLOCK; i++) {
    80000d8c:	07a1                	addi	a5,a5,8
    80000d8e:	fed798e3          	bne	a5,a3,80000d7e <sys_ntas+0x56>
    }
    return 0;
    80000d92:	4501                	li	a0,0
    80000d94:	a225                	j	80000ebc <sys_ntas+0x194>
  }

  printf("=== lock kmem/bcache stats\n");
    80000d96:	00007517          	auipc	a0,0x7
    80000d9a:	50250513          	addi	a0,a0,1282 # 80008298 <userret+0x208>
    80000d9e:	00000097          	auipc	ra,0x0
    80000da2:	83a080e7          	jalr	-1990(ra) # 800005d8 <printf>
  for(int i = 0; i < NLOCK; i++) {
    if(locks[i] == 0)
    80000da6:	00012797          	auipc	a5,0x12
    80000daa:	c7278793          	addi	a5,a5,-910 # 80012a18 <locks>
    80000dae:	639c                	ld	a5,0(a5)
    80000db0:	c3d1                	beqz	a5,80000e34 <sys_ntas+0x10c>
    80000db2:	00012497          	auipc	s1,0x12
    80000db6:	c6648493          	addi	s1,s1,-922 # 80012a18 <locks>
    80000dba:	00014a97          	auipc	s5,0x14
    80000dbe:	b96a8a93          	addi	s5,s5,-1130 # 80014950 <locks+0x1f38>
  int tot = 0;
    80000dc2:	4981                	li	s3,0
      break;
    if(strncmp(locks[i]->name, "bcache", strlen("bcache")) == 0 ||
    80000dc4:	00007917          	auipc	s2,0x7
    80000dc8:	4f490913          	addi	s2,s2,1268 # 800082b8 <userret+0x228>
       strncmp(locks[i]->name, "kmem", strlen("kmem")) == 0) {
    80000dcc:	00007b17          	auipc	s6,0x7
    80000dd0:	454b0b13          	addi	s6,s6,1108 # 80008220 <userret+0x190>
    80000dd4:	a831                	j	80000df0 <sys_ntas+0xc8>
      tot += locks[i]->nts;
    80000dd6:	6088                	ld	a0,0(s1)
    80000dd8:	4d5c                	lw	a5,28(a0)
    80000dda:	013789bb          	addw	s3,a5,s3
      print_lock(locks[i]);
    80000dde:	00000097          	auipc	ra,0x0
    80000de2:	f20080e7          	jalr	-224(ra) # 80000cfe <print_lock>
  for(int i = 0; i < NLOCK; i++) {
    80000de6:	05548863          	beq	s1,s5,80000e36 <sys_ntas+0x10e>
    if(locks[i] == 0)
    80000dea:	04a1                	addi	s1,s1,8
    80000dec:	609c                	ld	a5,0(s1)
    80000dee:	c7a1                	beqz	a5,80000e36 <sys_ntas+0x10e>
    if(strncmp(locks[i]->name, "bcache", strlen("bcache")) == 0 ||
    80000df0:	0087ba03          	ld	s4,8(a5)
    80000df4:	854a                	mv	a0,s2
    80000df6:	00000097          	auipc	ra,0x0
    80000dfa:	290080e7          	jalr	656(ra) # 80001086 <strlen>
    80000dfe:	0005061b          	sext.w	a2,a0
    80000e02:	85ca                	mv	a1,s2
    80000e04:	8552                	mv	a0,s4
    80000e06:	00000097          	auipc	ra,0x0
    80000e0a:	1be080e7          	jalr	446(ra) # 80000fc4 <strncmp>
    80000e0e:	d561                	beqz	a0,80000dd6 <sys_ntas+0xae>
       strncmp(locks[i]->name, "kmem", strlen("kmem")) == 0) {
    80000e10:	609c                	ld	a5,0(s1)
    80000e12:	0087ba03          	ld	s4,8(a5)
    80000e16:	855a                	mv	a0,s6
    80000e18:	00000097          	auipc	ra,0x0
    80000e1c:	26e080e7          	jalr	622(ra) # 80001086 <strlen>
    80000e20:	0005061b          	sext.w	a2,a0
    80000e24:	85da                	mv	a1,s6
    80000e26:	8552                	mv	a0,s4
    80000e28:	00000097          	auipc	ra,0x0
    80000e2c:	19c080e7          	jalr	412(ra) # 80000fc4 <strncmp>
    if(strncmp(locks[i]->name, "bcache", strlen("bcache")) == 0 ||
    80000e30:	f95d                	bnez	a0,80000de6 <sys_ntas+0xbe>
    80000e32:	b755                	j	80000dd6 <sys_ntas+0xae>
  int tot = 0;
    80000e34:	4981                	li	s3,0
    }
  }

  printf("=== top 5 contended locks:\n");
    80000e36:	00007517          	auipc	a0,0x7
    80000e3a:	48a50513          	addi	a0,a0,1162 # 800082c0 <userret+0x230>
    80000e3e:	fffff097          	auipc	ra,0xfffff
    80000e42:	79a080e7          	jalr	1946(ra) # 800005d8 <printf>
    80000e46:	4a15                	li	s4,5
  int last = 100000000;
    80000e48:	05f5e537          	lui	a0,0x5f5e
    80000e4c:	10050513          	addi	a0,a0,256 # 5f5e100 <_entry-0x7a0a1f00>
  // stupid way to compute top 5 contended locks
  for(int t= 0; t < 5; t++) {
    int top = 0;
    for(int i = 0; i < NLOCK; i++) {
      if(locks[i] == 0)
    80000e50:	00012497          	auipc	s1,0x12
    80000e54:	bc848493          	addi	s1,s1,-1080 # 80012a18 <locks>
    for(int i = 0; i < NLOCK; i++) {
    80000e58:	4a81                	li	s5,0
    80000e5a:	3e800913          	li	s2,1000
    80000e5e:	a0a1                	j	80000ea6 <sys_ntas+0x17e>
    80000e60:	2705                	addiw	a4,a4,1
    80000e62:	03270363          	beq	a4,s2,80000e88 <sys_ntas+0x160>
      if(locks[i] == 0)
    80000e66:	06a1                	addi	a3,a3,8
    80000e68:	ff86b783          	ld	a5,-8(a3)
    80000e6c:	cf91                	beqz	a5,80000e88 <sys_ntas+0x160>
        break;
      if(locks[i]->nts > locks[top]->nts && locks[i]->nts < last) {
    80000e6e:	4fd0                	lw	a2,28(a5)
    80000e70:	00359793          	slli	a5,a1,0x3
    80000e74:	97a6                	add	a5,a5,s1
    80000e76:	639c                	ld	a5,0(a5)
    80000e78:	4fdc                	lw	a5,28(a5)
    80000e7a:	fec7f3e3          	bleu	a2,a5,80000e60 <sys_ntas+0x138>
    80000e7e:	fea671e3          	bleu	a0,a2,80000e60 <sys_ntas+0x138>
    80000e82:	85ba                	mv	a1,a4
    80000e84:	bff1                	j	80000e60 <sys_ntas+0x138>
    int top = 0;
    80000e86:	85d6                	mv	a1,s5
        top = i;
      }
    }
    print_lock(locks[top]);
    80000e88:	058e                	slli	a1,a1,0x3
    80000e8a:	00b48b33          	add	s6,s1,a1
    80000e8e:	000b3503          	ld	a0,0(s6)
    80000e92:	00000097          	auipc	ra,0x0
    80000e96:	e6c080e7          	jalr	-404(ra) # 80000cfe <print_lock>
    last = locks[top]->nts;
    80000e9a:	000b3783          	ld	a5,0(s6)
    80000e9e:	4fc8                	lw	a0,28(a5)
  for(int t= 0; t < 5; t++) {
    80000ea0:	3a7d                	addiw	s4,s4,-1
    80000ea2:	000a0c63          	beqz	s4,80000eba <sys_ntas+0x192>
      if(locks[i] == 0)
    80000ea6:	609c                	ld	a5,0(s1)
    80000ea8:	dff9                	beqz	a5,80000e86 <sys_ntas+0x15e>
    80000eaa:	00012697          	auipc	a3,0x12
    80000eae:	b7668693          	addi	a3,a3,-1162 # 80012a20 <locks+0x8>
    for(int i = 0; i < NLOCK; i++) {
    80000eb2:	8756                	mv	a4,s5
    int top = 0;
    80000eb4:	85d6                	mv	a1,s5
      if(locks[i]->nts > locks[top]->nts && locks[i]->nts < last) {
    80000eb6:	2501                	sext.w	a0,a0
    80000eb8:	bf5d                	j	80000e6e <sys_ntas+0x146>
  }
  return tot;
    80000eba:	854e                	mv	a0,s3
}
    80000ebc:	60a6                	ld	ra,72(sp)
    80000ebe:	6406                	ld	s0,64(sp)
    80000ec0:	74e2                	ld	s1,56(sp)
    80000ec2:	7942                	ld	s2,48(sp)
    80000ec4:	79a2                	ld	s3,40(sp)
    80000ec6:	7a02                	ld	s4,32(sp)
    80000ec8:	6ae2                	ld	s5,24(sp)
    80000eca:	6b42                	ld	s6,16(sp)
    80000ecc:	6161                	addi	sp,sp,80
    80000ece:	8082                	ret
    return -1;
    80000ed0:	557d                	li	a0,-1
    80000ed2:	b7ed                	j	80000ebc <sys_ntas+0x194>
    return 0;
    80000ed4:	4501                	li	a0,0
    80000ed6:	b7dd                	j	80000ebc <sys_ntas+0x194>
    80000ed8:	4501                	li	a0,0
    80000eda:	b7cd                	j	80000ebc <sys_ntas+0x194>

0000000080000edc <memset>:
#include "types.h"

void*
memset(void *dst, int c, uint n)
{
    80000edc:	1141                	addi	sp,sp,-16
    80000ede:	e422                	sd	s0,8(sp)
    80000ee0:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
    80000ee2:	ce09                	beqz	a2,80000efc <memset+0x20>
    80000ee4:	87aa                	mv	a5,a0
    80000ee6:	fff6071b          	addiw	a4,a2,-1
    80000eea:	1702                	slli	a4,a4,0x20
    80000eec:	9301                	srli	a4,a4,0x20
    80000eee:	0705                	addi	a4,a4,1
    80000ef0:	972a                	add	a4,a4,a0
    cdst[i] = c;
    80000ef2:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
    80000ef6:	0785                	addi	a5,a5,1
    80000ef8:	fee79de3          	bne	a5,a4,80000ef2 <memset+0x16>
  }
  return dst;
}
    80000efc:	6422                	ld	s0,8(sp)
    80000efe:	0141                	addi	sp,sp,16
    80000f00:	8082                	ret

0000000080000f02 <memcmp>:

int
memcmp(const void *v1, const void *v2, uint n)
{
    80000f02:	1141                	addi	sp,sp,-16
    80000f04:	e422                	sd	s0,8(sp)
    80000f06:	0800                	addi	s0,sp,16
  const uchar *s1, *s2;

  s1 = v1;
  s2 = v2;
  while(n-- > 0){
    80000f08:	ce15                	beqz	a2,80000f44 <memcmp+0x42>
    80000f0a:	fff6069b          	addiw	a3,a2,-1
    if(*s1 != *s2)
    80000f0e:	00054783          	lbu	a5,0(a0)
    80000f12:	0005c703          	lbu	a4,0(a1)
    80000f16:	02e79063          	bne	a5,a4,80000f36 <memcmp+0x34>
    80000f1a:	1682                	slli	a3,a3,0x20
    80000f1c:	9281                	srli	a3,a3,0x20
    80000f1e:	0685                	addi	a3,a3,1
    80000f20:	96aa                	add	a3,a3,a0
      return *s1 - *s2;
    s1++, s2++;
    80000f22:	0505                	addi	a0,a0,1
    80000f24:	0585                	addi	a1,a1,1
  while(n-- > 0){
    80000f26:	00d50d63          	beq	a0,a3,80000f40 <memcmp+0x3e>
    if(*s1 != *s2)
    80000f2a:	00054783          	lbu	a5,0(a0)
    80000f2e:	0005c703          	lbu	a4,0(a1)
    80000f32:	fee788e3          	beq	a5,a4,80000f22 <memcmp+0x20>
      return *s1 - *s2;
    80000f36:	40e7853b          	subw	a0,a5,a4
  }

  return 0;
}
    80000f3a:	6422                	ld	s0,8(sp)
    80000f3c:	0141                	addi	sp,sp,16
    80000f3e:	8082                	ret
  return 0;
    80000f40:	4501                	li	a0,0
    80000f42:	bfe5                	j	80000f3a <memcmp+0x38>
    80000f44:	4501                	li	a0,0
    80000f46:	bfd5                	j	80000f3a <memcmp+0x38>

0000000080000f48 <memmove>:

void*
memmove(void *dst, const void *src, uint n)
{
    80000f48:	1141                	addi	sp,sp,-16
    80000f4a:	e422                	sd	s0,8(sp)
    80000f4c:	0800                	addi	s0,sp,16
  const char *s;
  char *d;

  s = src;
  d = dst;
  if(s < d && s + n > d){
    80000f4e:	00a5f963          	bleu	a0,a1,80000f60 <memmove+0x18>
    80000f52:	02061713          	slli	a4,a2,0x20
    80000f56:	9301                	srli	a4,a4,0x20
    80000f58:	00e587b3          	add	a5,a1,a4
    80000f5c:	02f56563          	bltu	a0,a5,80000f86 <memmove+0x3e>
    s += n;
    d += n;
    while(n-- > 0)
      *--d = *--s;
  } else
    while(n-- > 0)
    80000f60:	fff6069b          	addiw	a3,a2,-1
    80000f64:	ce11                	beqz	a2,80000f80 <memmove+0x38>
    80000f66:	1682                	slli	a3,a3,0x20
    80000f68:	9281                	srli	a3,a3,0x20
    80000f6a:	0685                	addi	a3,a3,1
    80000f6c:	96ae                	add	a3,a3,a1
    80000f6e:	87aa                	mv	a5,a0
      *d++ = *s++;
    80000f70:	0585                	addi	a1,a1,1
    80000f72:	0785                	addi	a5,a5,1
    80000f74:	fff5c703          	lbu	a4,-1(a1)
    80000f78:	fee78fa3          	sb	a4,-1(a5)
    while(n-- > 0)
    80000f7c:	fed59ae3          	bne	a1,a3,80000f70 <memmove+0x28>

  return dst;
}
    80000f80:	6422                	ld	s0,8(sp)
    80000f82:	0141                	addi	sp,sp,16
    80000f84:	8082                	ret
    d += n;
    80000f86:	972a                	add	a4,a4,a0
    while(n-- > 0)
    80000f88:	fff6069b          	addiw	a3,a2,-1
    80000f8c:	da75                	beqz	a2,80000f80 <memmove+0x38>
    80000f8e:	02069613          	slli	a2,a3,0x20
    80000f92:	9201                	srli	a2,a2,0x20
    80000f94:	fff64613          	not	a2,a2
    80000f98:	963e                	add	a2,a2,a5
      *--d = *--s;
    80000f9a:	17fd                	addi	a5,a5,-1
    80000f9c:	177d                	addi	a4,a4,-1
    80000f9e:	0007c683          	lbu	a3,0(a5)
    80000fa2:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
    80000fa6:	fef61ae3          	bne	a2,a5,80000f9a <memmove+0x52>
    80000faa:	bfd9                	j	80000f80 <memmove+0x38>

0000000080000fac <memcpy>:

// memcpy exists to placate GCC.  Use memmove.
void*
memcpy(void *dst, const void *src, uint n)
{
    80000fac:	1141                	addi	sp,sp,-16
    80000fae:	e406                	sd	ra,8(sp)
    80000fb0:	e022                	sd	s0,0(sp)
    80000fb2:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
    80000fb4:	00000097          	auipc	ra,0x0
    80000fb8:	f94080e7          	jalr	-108(ra) # 80000f48 <memmove>
}
    80000fbc:	60a2                	ld	ra,8(sp)
    80000fbe:	6402                	ld	s0,0(sp)
    80000fc0:	0141                	addi	sp,sp,16
    80000fc2:	8082                	ret

0000000080000fc4 <strncmp>:

int
strncmp(const char *p, const char *q, uint n)
{
    80000fc4:	1141                	addi	sp,sp,-16
    80000fc6:	e422                	sd	s0,8(sp)
    80000fc8:	0800                	addi	s0,sp,16
  while(n > 0 && *p && *p == *q)
    80000fca:	c229                	beqz	a2,8000100c <strncmp+0x48>
    80000fcc:	00054783          	lbu	a5,0(a0)
    80000fd0:	c795                	beqz	a5,80000ffc <strncmp+0x38>
    80000fd2:	0005c703          	lbu	a4,0(a1)
    80000fd6:	02f71363          	bne	a4,a5,80000ffc <strncmp+0x38>
    80000fda:	fff6071b          	addiw	a4,a2,-1
    80000fde:	1702                	slli	a4,a4,0x20
    80000fe0:	9301                	srli	a4,a4,0x20
    80000fe2:	0705                	addi	a4,a4,1
    80000fe4:	972a                	add	a4,a4,a0
    n--, p++, q++;
    80000fe6:	0505                	addi	a0,a0,1
    80000fe8:	0585                	addi	a1,a1,1
  while(n > 0 && *p && *p == *q)
    80000fea:	02e50363          	beq	a0,a4,80001010 <strncmp+0x4c>
    80000fee:	00054783          	lbu	a5,0(a0)
    80000ff2:	c789                	beqz	a5,80000ffc <strncmp+0x38>
    80000ff4:	0005c683          	lbu	a3,0(a1)
    80000ff8:	fef687e3          	beq	a3,a5,80000fe6 <strncmp+0x22>
  if(n == 0)
    return 0;
  return (uchar)*p - (uchar)*q;
    80000ffc:	00054503          	lbu	a0,0(a0)
    80001000:	0005c783          	lbu	a5,0(a1)
    80001004:	9d1d                	subw	a0,a0,a5
}
    80001006:	6422                	ld	s0,8(sp)
    80001008:	0141                	addi	sp,sp,16
    8000100a:	8082                	ret
    return 0;
    8000100c:	4501                	li	a0,0
    8000100e:	bfe5                	j	80001006 <strncmp+0x42>
    80001010:	4501                	li	a0,0
    80001012:	bfd5                	j	80001006 <strncmp+0x42>

0000000080001014 <strncpy>:

char*
strncpy(char *s, const char *t, int n)
{
    80001014:	1141                	addi	sp,sp,-16
    80001016:	e422                	sd	s0,8(sp)
    80001018:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while(n-- > 0 && (*s++ = *t++) != 0)
    8000101a:	872a                	mv	a4,a0
    8000101c:	a011                	j	80001020 <strncpy+0xc>
    8000101e:	8636                	mv	a2,a3
    80001020:	fff6069b          	addiw	a3,a2,-1
    80001024:	00c05963          	blez	a2,80001036 <strncpy+0x22>
    80001028:	0705                	addi	a4,a4,1
    8000102a:	0005c783          	lbu	a5,0(a1)
    8000102e:	fef70fa3          	sb	a5,-1(a4)
    80001032:	0585                	addi	a1,a1,1
    80001034:	f7ed                	bnez	a5,8000101e <strncpy+0xa>
    ;
  while(n-- > 0)
    80001036:	00d05c63          	blez	a3,8000104e <strncpy+0x3a>
    8000103a:	86ba                	mv	a3,a4
    *s++ = 0;
    8000103c:	0685                	addi	a3,a3,1
    8000103e:	fe068fa3          	sb	zero,-1(a3)
  while(n-- > 0)
    80001042:	fff6c793          	not	a5,a3
    80001046:	9fb9                	addw	a5,a5,a4
    80001048:	9fb1                	addw	a5,a5,a2
    8000104a:	fef049e3          	bgtz	a5,8000103c <strncpy+0x28>
  return os;
}
    8000104e:	6422                	ld	s0,8(sp)
    80001050:	0141                	addi	sp,sp,16
    80001052:	8082                	ret

0000000080001054 <safestrcpy>:

// Like strncpy but guaranteed to NUL-terminate.
char*
safestrcpy(char *s, const char *t, int n)
{
    80001054:	1141                	addi	sp,sp,-16
    80001056:	e422                	sd	s0,8(sp)
    80001058:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  if(n <= 0)
    8000105a:	02c05363          	blez	a2,80001080 <safestrcpy+0x2c>
    8000105e:	fff6069b          	addiw	a3,a2,-1
    80001062:	1682                	slli	a3,a3,0x20
    80001064:	9281                	srli	a3,a3,0x20
    80001066:	96ae                	add	a3,a3,a1
    80001068:	87aa                	mv	a5,a0
    return os;
  while(--n > 0 && (*s++ = *t++) != 0)
    8000106a:	00d58963          	beq	a1,a3,8000107c <safestrcpy+0x28>
    8000106e:	0585                	addi	a1,a1,1
    80001070:	0785                	addi	a5,a5,1
    80001072:	fff5c703          	lbu	a4,-1(a1)
    80001076:	fee78fa3          	sb	a4,-1(a5)
    8000107a:	fb65                	bnez	a4,8000106a <safestrcpy+0x16>
    ;
  *s = 0;
    8000107c:	00078023          	sb	zero,0(a5)
  return os;
}
    80001080:	6422                	ld	s0,8(sp)
    80001082:	0141                	addi	sp,sp,16
    80001084:	8082                	ret

0000000080001086 <strlen>:

int
strlen(const char *s)
{
    80001086:	1141                	addi	sp,sp,-16
    80001088:	e422                	sd	s0,8(sp)
    8000108a:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
    8000108c:	00054783          	lbu	a5,0(a0)
    80001090:	cf91                	beqz	a5,800010ac <strlen+0x26>
    80001092:	0505                	addi	a0,a0,1
    80001094:	87aa                	mv	a5,a0
    80001096:	4685                	li	a3,1
    80001098:	9e89                	subw	a3,a3,a0
    8000109a:	00f6853b          	addw	a0,a3,a5
    8000109e:	0785                	addi	a5,a5,1
    800010a0:	fff7c703          	lbu	a4,-1(a5)
    800010a4:	fb7d                	bnez	a4,8000109a <strlen+0x14>
    ;
  return n;
}
    800010a6:	6422                	ld	s0,8(sp)
    800010a8:	0141                	addi	sp,sp,16
    800010aa:	8082                	ret
  for(n = 0; s[n]; n++)
    800010ac:	4501                	li	a0,0
    800010ae:	bfe5                	j	800010a6 <strlen+0x20>

00000000800010b0 <main>:
volatile static int started = 0;

// start() jumps here in supervisor mode on all CPUs.
void
main()
{
    800010b0:	1141                	addi	sp,sp,-16
    800010b2:	e406                	sd	ra,8(sp)
    800010b4:	e022                	sd	s0,0(sp)
    800010b6:	0800                	addi	s0,sp,16
  if(cpuid() == 0){
    800010b8:	00001097          	auipc	ra,0x1
    800010bc:	b22080e7          	jalr	-1246(ra) # 80001bda <cpuid>
    virtio_disk_init(minor(ROOTDEV)); // emulated hard disk
    userinit();      // first user process
    __sync_synchronize();
    started = 1;
  } else {
    while(started == 0)
    800010c0:	0002f717          	auipc	a4,0x2f
    800010c4:	f6870713          	addi	a4,a4,-152 # 80030028 <started>
  if(cpuid() == 0){
    800010c8:	c139                	beqz	a0,8000110e <main+0x5e>
    while(started == 0)
    800010ca:	431c                	lw	a5,0(a4)
    800010cc:	2781                	sext.w	a5,a5
    800010ce:	dff5                	beqz	a5,800010ca <main+0x1a>
      ;
    __sync_synchronize();
    800010d0:	0ff0000f          	fence
    printf("hart %d starting\n", cpuid());
    800010d4:	00001097          	auipc	ra,0x1
    800010d8:	b06080e7          	jalr	-1274(ra) # 80001bda <cpuid>
    800010dc:	85aa                	mv	a1,a0
    800010de:	00007517          	auipc	a0,0x7
    800010e2:	21a50513          	addi	a0,a0,538 # 800082f8 <userret+0x268>
    800010e6:	fffff097          	auipc	ra,0xfffff
    800010ea:	4f2080e7          	jalr	1266(ra) # 800005d8 <printf>
    kvminithart();    // turn on paging
    800010ee:	00000097          	auipc	ra,0x0
    800010f2:	1ea080e7          	jalr	490(ra) # 800012d8 <kvminithart>
    trapinithart();   // install kernel trap vector
    800010f6:	00001097          	auipc	ra,0x1
    800010fa:	73c080e7          	jalr	1852(ra) # 80002832 <trapinithart>
    plicinithart();   // ask PLIC for device interrupts
    800010fe:	00005097          	auipc	ra,0x5
    80001102:	fd2080e7          	jalr	-46(ra) # 800060d0 <plicinithart>
  }

  scheduler();        
    80001106:	00001097          	auipc	ra,0x1
    8000110a:	fe0080e7          	jalr	-32(ra) # 800020e6 <scheduler>
    consoleinit();
    8000110e:	fffff097          	auipc	ra,0xfffff
    80001112:	37e080e7          	jalr	894(ra) # 8000048c <consoleinit>
    printfinit();
    80001116:	fffff097          	auipc	ra,0xfffff
    8000111a:	6a8080e7          	jalr	1704(ra) # 800007be <printfinit>
    printf("\n");
    8000111e:	00007517          	auipc	a0,0x7
    80001122:	17250513          	addi	a0,a0,370 # 80008290 <userret+0x200>
    80001126:	fffff097          	auipc	ra,0xfffff
    8000112a:	4b2080e7          	jalr	1202(ra) # 800005d8 <printf>
    printf("xv6 kernel is booting\n");
    8000112e:	00007517          	auipc	a0,0x7
    80001132:	1b250513          	addi	a0,a0,434 # 800082e0 <userret+0x250>
    80001136:	fffff097          	auipc	ra,0xfffff
    8000113a:	4a2080e7          	jalr	1186(ra) # 800005d8 <printf>
    printf("\n");
    8000113e:	00007517          	auipc	a0,0x7
    80001142:	15250513          	addi	a0,a0,338 # 80008290 <userret+0x200>
    80001146:	fffff097          	auipc	ra,0xfffff
    8000114a:	492080e7          	jalr	1170(ra) # 800005d8 <printf>
    kinit();         // physical page allocator
    8000114e:	00000097          	auipc	ra,0x0
    80001152:	84a080e7          	jalr	-1974(ra) # 80000998 <kinit>
    kvminit();       // create kernel page table
    80001156:	00000097          	auipc	ra,0x0
    8000115a:	312080e7          	jalr	786(ra) # 80001468 <kvminit>
    kvminithart();   // turn on paging
    8000115e:	00000097          	auipc	ra,0x0
    80001162:	17a080e7          	jalr	378(ra) # 800012d8 <kvminithart>
    procinit();      // process table
    80001166:	00001097          	auipc	ra,0x1
    8000116a:	9a4080e7          	jalr	-1628(ra) # 80001b0a <procinit>
    trapinit();      // trap vectors
    8000116e:	00001097          	auipc	ra,0x1
    80001172:	69c080e7          	jalr	1692(ra) # 8000280a <trapinit>
    trapinithart();  // install kernel trap vector
    80001176:	00001097          	auipc	ra,0x1
    8000117a:	6bc080e7          	jalr	1724(ra) # 80002832 <trapinithart>
    plicinit();      // set up interrupt controller
    8000117e:	00005097          	auipc	ra,0x5
    80001182:	f3c080e7          	jalr	-196(ra) # 800060ba <plicinit>
    plicinithart();  // ask PLIC for device interrupts
    80001186:	00005097          	auipc	ra,0x5
    8000118a:	f4a080e7          	jalr	-182(ra) # 800060d0 <plicinithart>
    binit();         // buffer cache
    8000118e:	00002097          	auipc	ra,0x2
    80001192:	df0080e7          	jalr	-528(ra) # 80002f7e <binit>
    iinit();         // inode cache
    80001196:	00002097          	auipc	ra,0x2
    8000119a:	5e2080e7          	jalr	1506(ra) # 80003778 <iinit>
    fileinit();      // file table
    8000119e:	00003097          	auipc	ra,0x3
    800011a2:	698080e7          	jalr	1688(ra) # 80004836 <fileinit>
    virtio_disk_init(minor(ROOTDEV)); // emulated hard disk
    800011a6:	4501                	li	a0,0
    800011a8:	00005097          	auipc	ra,0x5
    800011ac:	048080e7          	jalr	72(ra) # 800061f0 <virtio_disk_init>
    userinit();      // first user process
    800011b0:	00001097          	auipc	ra,0x1
    800011b4:	ccc080e7          	jalr	-820(ra) # 80001e7c <userinit>
    __sync_synchronize();
    800011b8:	0ff0000f          	fence
    started = 1;
    800011bc:	4785                	li	a5,1
    800011be:	0002f717          	auipc	a4,0x2f
    800011c2:	e6f72523          	sw	a5,-406(a4) # 80030028 <started>
    800011c6:	b781                	j	80001106 <main+0x56>

00000000800011c8 <walk>:
//   21..39 -- 9 bits of level-1 index.
//   12..20 -- 9 bits of level-0 index.
//    0..12 -- 12 bits of byte offset within the page.
static pte_t *
walk(pagetable_t pagetable, uint64 va, int alloc)
{
    800011c8:	7139                	addi	sp,sp,-64
    800011ca:	fc06                	sd	ra,56(sp)
    800011cc:	f822                	sd	s0,48(sp)
    800011ce:	f426                	sd	s1,40(sp)
    800011d0:	f04a                	sd	s2,32(sp)
    800011d2:	ec4e                	sd	s3,24(sp)
    800011d4:	e852                	sd	s4,16(sp)
    800011d6:	e456                	sd	s5,8(sp)
    800011d8:	e05a                	sd	s6,0(sp)
    800011da:	0080                	addi	s0,sp,64
    800011dc:	84aa                	mv	s1,a0
    800011de:	89ae                	mv	s3,a1
    800011e0:	8b32                	mv	s6,a2
  if(va >= MAXVA)
    800011e2:	57fd                	li	a5,-1
    800011e4:	83e9                	srli	a5,a5,0x1a
    800011e6:	4a79                	li	s4,30
    panic("walk");

  for(int level = 2; level > 0; level--) {
    800011e8:	4ab1                	li	s5,12
  if(va >= MAXVA)
    800011ea:	04b7f263          	bleu	a1,a5,8000122e <walk+0x66>
    panic("walk");
    800011ee:	00007517          	auipc	a0,0x7
    800011f2:	12250513          	addi	a0,a0,290 # 80008310 <userret+0x280>
    800011f6:	fffff097          	auipc	ra,0xfffff
    800011fa:	388080e7          	jalr	904(ra) # 8000057e <panic>
    pte_t *pte = &pagetable[PX(level, va)];
    if(*pte & PTE_V) {
      pagetable = (pagetable_t)PTE2PA(*pte);
    } else {
      if(!alloc || (pagetable = (pde_t*)kalloc()) == 0)
    800011fe:	060b0663          	beqz	s6,8000126a <walk+0xa2>
    80001202:	fffff097          	auipc	ra,0xfffff
    80001206:	7f2080e7          	jalr	2034(ra) # 800009f4 <kalloc>
    8000120a:	84aa                	mv	s1,a0
    8000120c:	c529                	beqz	a0,80001256 <walk+0x8e>
        return 0;
      memset(pagetable, 0, PGSIZE);
    8000120e:	6605                	lui	a2,0x1
    80001210:	4581                	li	a1,0
    80001212:	00000097          	auipc	ra,0x0
    80001216:	cca080e7          	jalr	-822(ra) # 80000edc <memset>
      *pte = PA2PTE(pagetable) | PTE_V;
    8000121a:	00c4d793          	srli	a5,s1,0xc
    8000121e:	07aa                	slli	a5,a5,0xa
    80001220:	0017e793          	ori	a5,a5,1
    80001224:	00f93023          	sd	a5,0(s2)
  for(int level = 2; level > 0; level--) {
    80001228:	3a5d                	addiw	s4,s4,-9
    8000122a:	035a0063          	beq	s4,s5,8000124a <walk+0x82>
    pte_t *pte = &pagetable[PX(level, va)];
    8000122e:	0149d933          	srl	s2,s3,s4
    80001232:	1ff97913          	andi	s2,s2,511
    80001236:	090e                	slli	s2,s2,0x3
    80001238:	9926                	add	s2,s2,s1
    if(*pte & PTE_V) {
    8000123a:	00093483          	ld	s1,0(s2)
    8000123e:	0014f793          	andi	a5,s1,1
    80001242:	dfd5                	beqz	a5,800011fe <walk+0x36>
      pagetable = (pagetable_t)PTE2PA(*pte);
    80001244:	80a9                	srli	s1,s1,0xa
    80001246:	04b2                	slli	s1,s1,0xc
    80001248:	b7c5                	j	80001228 <walk+0x60>
    }
  }
  return &pagetable[PX(0, va)];
    8000124a:	00c9d513          	srli	a0,s3,0xc
    8000124e:	1ff57513          	andi	a0,a0,511
    80001252:	050e                	slli	a0,a0,0x3
    80001254:	9526                	add	a0,a0,s1
}
    80001256:	70e2                	ld	ra,56(sp)
    80001258:	7442                	ld	s0,48(sp)
    8000125a:	74a2                	ld	s1,40(sp)
    8000125c:	7902                	ld	s2,32(sp)
    8000125e:	69e2                	ld	s3,24(sp)
    80001260:	6a42                	ld	s4,16(sp)
    80001262:	6aa2                	ld	s5,8(sp)
    80001264:	6b02                	ld	s6,0(sp)
    80001266:	6121                	addi	sp,sp,64
    80001268:	8082                	ret
        return 0;
    8000126a:	4501                	li	a0,0
    8000126c:	b7ed                	j	80001256 <walk+0x8e>

000000008000126e <freewalk>:

// Recursively free page-table pages.
// All leaf mappings must already have been removed.
static void
freewalk(pagetable_t pagetable)
{
    8000126e:	7179                	addi	sp,sp,-48
    80001270:	f406                	sd	ra,40(sp)
    80001272:	f022                	sd	s0,32(sp)
    80001274:	ec26                	sd	s1,24(sp)
    80001276:	e84a                	sd	s2,16(sp)
    80001278:	e44e                	sd	s3,8(sp)
    8000127a:	e052                	sd	s4,0(sp)
    8000127c:	1800                	addi	s0,sp,48
    8000127e:	8a2a                	mv	s4,a0
  // there are 2^9 = 512 PTEs in a page table.
  for(int i = 0; i < 512; i++){
    80001280:	84aa                	mv	s1,a0
    80001282:	6905                	lui	s2,0x1
    80001284:	992a                	add	s2,s2,a0
    pte_t pte = pagetable[i];
    if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
    80001286:	4985                	li	s3,1
    80001288:	a821                	j	800012a0 <freewalk+0x32>
      // this PTE points to a lower-level page table.
      uint64 child = PTE2PA(pte);
    8000128a:	8129                	srli	a0,a0,0xa
      freewalk((pagetable_t)child);
    8000128c:	0532                	slli	a0,a0,0xc
    8000128e:	00000097          	auipc	ra,0x0
    80001292:	fe0080e7          	jalr	-32(ra) # 8000126e <freewalk>
      pagetable[i] = 0;
    80001296:	0004b023          	sd	zero,0(s1)
  for(int i = 0; i < 512; i++){
    8000129a:	04a1                	addi	s1,s1,8
    8000129c:	03248163          	beq	s1,s2,800012be <freewalk+0x50>
    pte_t pte = pagetable[i];
    800012a0:	6088                	ld	a0,0(s1)
    if((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0){
    800012a2:	00f57793          	andi	a5,a0,15
    800012a6:	ff3782e3          	beq	a5,s3,8000128a <freewalk+0x1c>
    } else if(pte & PTE_V){
    800012aa:	8905                	andi	a0,a0,1
    800012ac:	d57d                	beqz	a0,8000129a <freewalk+0x2c>
      panic("freewalk: leaf");
    800012ae:	00007517          	auipc	a0,0x7
    800012b2:	06a50513          	addi	a0,a0,106 # 80008318 <userret+0x288>
    800012b6:	fffff097          	auipc	ra,0xfffff
    800012ba:	2c8080e7          	jalr	712(ra) # 8000057e <panic>
    }
  }
  kfree((void*)pagetable);
    800012be:	8552                	mv	a0,s4
    800012c0:	fffff097          	auipc	ra,0xfffff
    800012c4:	5e4080e7          	jalr	1508(ra) # 800008a4 <kfree>
}
    800012c8:	70a2                	ld	ra,40(sp)
    800012ca:	7402                	ld	s0,32(sp)
    800012cc:	64e2                	ld	s1,24(sp)
    800012ce:	6942                	ld	s2,16(sp)
    800012d0:	69a2                	ld	s3,8(sp)
    800012d2:	6a02                	ld	s4,0(sp)
    800012d4:	6145                	addi	sp,sp,48
    800012d6:	8082                	ret

00000000800012d8 <kvminithart>:
{
    800012d8:	1141                	addi	sp,sp,-16
    800012da:	e422                	sd	s0,8(sp)
    800012dc:	0800                	addi	s0,sp,16
  w_satp(MAKE_SATP(kernel_pagetable));
    800012de:	0002f797          	auipc	a5,0x2f
    800012e2:	d5278793          	addi	a5,a5,-686 # 80030030 <kernel_pagetable>
    800012e6:	639c                	ld	a5,0(a5)
    800012e8:	83b1                	srli	a5,a5,0xc
    800012ea:	577d                	li	a4,-1
    800012ec:	177e                	slli	a4,a4,0x3f
    800012ee:	8fd9                	or	a5,a5,a4
  asm volatile("csrw satp, %0" : : "r" (x));
    800012f0:	18079073          	csrw	satp,a5
// flush the TLB.
static inline void
sfence_vma()
{
  // the zero, zero means flush all TLB entries.
  asm volatile("sfence.vma zero, zero");
    800012f4:	12000073          	sfence.vma
}
    800012f8:	6422                	ld	s0,8(sp)
    800012fa:	0141                	addi	sp,sp,16
    800012fc:	8082                	ret

00000000800012fe <walkaddr>:
  if(va >= MAXVA)
    800012fe:	57fd                	li	a5,-1
    80001300:	83e9                	srli	a5,a5,0x1a
    80001302:	00b7f463          	bleu	a1,a5,8000130a <walkaddr+0xc>
    return 0;
    80001306:	4501                	li	a0,0
}
    80001308:	8082                	ret
{
    8000130a:	1141                	addi	sp,sp,-16
    8000130c:	e406                	sd	ra,8(sp)
    8000130e:	e022                	sd	s0,0(sp)
    80001310:	0800                	addi	s0,sp,16
  pte = walk(pagetable, va, 0);
    80001312:	4601                	li	a2,0
    80001314:	00000097          	auipc	ra,0x0
    80001318:	eb4080e7          	jalr	-332(ra) # 800011c8 <walk>
  if(pte == 0)
    8000131c:	c105                	beqz	a0,8000133c <walkaddr+0x3e>
  if((*pte & PTE_V) == 0)
    8000131e:	611c                	ld	a5,0(a0)
  if((*pte & PTE_U) == 0)
    80001320:	0117f693          	andi	a3,a5,17
    80001324:	4745                	li	a4,17
    return 0;
    80001326:	4501                	li	a0,0
  if((*pte & PTE_U) == 0)
    80001328:	00e68663          	beq	a3,a4,80001334 <walkaddr+0x36>
}
    8000132c:	60a2                	ld	ra,8(sp)
    8000132e:	6402                	ld	s0,0(sp)
    80001330:	0141                	addi	sp,sp,16
    80001332:	8082                	ret
  pa = PTE2PA(*pte);
    80001334:	00a7d513          	srli	a0,a5,0xa
    80001338:	0532                	slli	a0,a0,0xc
  return pa;
    8000133a:	bfcd                	j	8000132c <walkaddr+0x2e>
    return 0;
    8000133c:	4501                	li	a0,0
    8000133e:	b7fd                	j	8000132c <walkaddr+0x2e>

0000000080001340 <kvmpa>:
{
    80001340:	1101                	addi	sp,sp,-32
    80001342:	ec06                	sd	ra,24(sp)
    80001344:	e822                	sd	s0,16(sp)
    80001346:	e426                	sd	s1,8(sp)
    80001348:	1000                	addi	s0,sp,32
    8000134a:	85aa                	mv	a1,a0
  uint64 off = va % PGSIZE;
    8000134c:	6785                	lui	a5,0x1
    8000134e:	17fd                	addi	a5,a5,-1
    80001350:	00f574b3          	and	s1,a0,a5
  pte = walk(kernel_pagetable, va, 0);
    80001354:	4601                	li	a2,0
    80001356:	0002f797          	auipc	a5,0x2f
    8000135a:	cda78793          	addi	a5,a5,-806 # 80030030 <kernel_pagetable>
    8000135e:	6388                	ld	a0,0(a5)
    80001360:	00000097          	auipc	ra,0x0
    80001364:	e68080e7          	jalr	-408(ra) # 800011c8 <walk>
  if(pte == 0)
    80001368:	cd09                	beqz	a0,80001382 <kvmpa+0x42>
  if((*pte & PTE_V) == 0)
    8000136a:	6108                	ld	a0,0(a0)
    8000136c:	00157793          	andi	a5,a0,1
    80001370:	c38d                	beqz	a5,80001392 <kvmpa+0x52>
  pa = PTE2PA(*pte);
    80001372:	8129                	srli	a0,a0,0xa
    80001374:	0532                	slli	a0,a0,0xc
}
    80001376:	9526                	add	a0,a0,s1
    80001378:	60e2                	ld	ra,24(sp)
    8000137a:	6442                	ld	s0,16(sp)
    8000137c:	64a2                	ld	s1,8(sp)
    8000137e:	6105                	addi	sp,sp,32
    80001380:	8082                	ret
    panic("kvmpa");
    80001382:	00007517          	auipc	a0,0x7
    80001386:	fa650513          	addi	a0,a0,-90 # 80008328 <userret+0x298>
    8000138a:	fffff097          	auipc	ra,0xfffff
    8000138e:	1f4080e7          	jalr	500(ra) # 8000057e <panic>
    panic("kvmpa");
    80001392:	00007517          	auipc	a0,0x7
    80001396:	f9650513          	addi	a0,a0,-106 # 80008328 <userret+0x298>
    8000139a:	fffff097          	auipc	ra,0xfffff
    8000139e:	1e4080e7          	jalr	484(ra) # 8000057e <panic>

00000000800013a2 <mappages>:
{
    800013a2:	715d                	addi	sp,sp,-80
    800013a4:	e486                	sd	ra,72(sp)
    800013a6:	e0a2                	sd	s0,64(sp)
    800013a8:	fc26                	sd	s1,56(sp)
    800013aa:	f84a                	sd	s2,48(sp)
    800013ac:	f44e                	sd	s3,40(sp)
    800013ae:	f052                	sd	s4,32(sp)
    800013b0:	ec56                	sd	s5,24(sp)
    800013b2:	e85a                	sd	s6,16(sp)
    800013b4:	e45e                	sd	s7,8(sp)
    800013b6:	0880                	addi	s0,sp,80
    800013b8:	8aaa                	mv	s5,a0
    800013ba:	8b3a                	mv	s6,a4
  a = PGROUNDDOWN(va);
    800013bc:	79fd                	lui	s3,0xfffff
    800013be:	0135fa33          	and	s4,a1,s3
  last = PGROUNDDOWN(va + size - 1);
    800013c2:	167d                	addi	a2,a2,-1
    800013c4:	962e                	add	a2,a2,a1
    800013c6:	013679b3          	and	s3,a2,s3
  a = PGROUNDDOWN(va);
    800013ca:	8952                	mv	s2,s4
    800013cc:	41468a33          	sub	s4,a3,s4
    a += PGSIZE;
    800013d0:	6b85                	lui	s7,0x1
    800013d2:	a811                	j	800013e6 <mappages+0x44>
      panic("remap");
    800013d4:	00007517          	auipc	a0,0x7
    800013d8:	f5c50513          	addi	a0,a0,-164 # 80008330 <userret+0x2a0>
    800013dc:	fffff097          	auipc	ra,0xfffff
    800013e0:	1a2080e7          	jalr	418(ra) # 8000057e <panic>
    a += PGSIZE;
    800013e4:	995e                	add	s2,s2,s7
  for(;;){
    800013e6:	012a04b3          	add	s1,s4,s2
    if((pte = walk(pagetable, a, 1)) == 0)
    800013ea:	4605                	li	a2,1
    800013ec:	85ca                	mv	a1,s2
    800013ee:	8556                	mv	a0,s5
    800013f0:	00000097          	auipc	ra,0x0
    800013f4:	dd8080e7          	jalr	-552(ra) # 800011c8 <walk>
    800013f8:	cd19                	beqz	a0,80001416 <mappages+0x74>
    if(*pte & PTE_V)
    800013fa:	611c                	ld	a5,0(a0)
    800013fc:	8b85                	andi	a5,a5,1
    800013fe:	fbf9                	bnez	a5,800013d4 <mappages+0x32>
    *pte = PA2PTE(pa) | perm | PTE_V;
    80001400:	80b1                	srli	s1,s1,0xc
    80001402:	04aa                	slli	s1,s1,0xa
    80001404:	0164e4b3          	or	s1,s1,s6
    80001408:	0014e493          	ori	s1,s1,1
    8000140c:	e104                	sd	s1,0(a0)
    if(a == last)
    8000140e:	fd391be3          	bne	s2,s3,800013e4 <mappages+0x42>
  return 0;
    80001412:	4501                	li	a0,0
    80001414:	a011                	j	80001418 <mappages+0x76>
      return -1;
    80001416:	557d                	li	a0,-1
}
    80001418:	60a6                	ld	ra,72(sp)
    8000141a:	6406                	ld	s0,64(sp)
    8000141c:	74e2                	ld	s1,56(sp)
    8000141e:	7942                	ld	s2,48(sp)
    80001420:	79a2                	ld	s3,40(sp)
    80001422:	7a02                	ld	s4,32(sp)
    80001424:	6ae2                	ld	s5,24(sp)
    80001426:	6b42                	ld	s6,16(sp)
    80001428:	6ba2                	ld	s7,8(sp)
    8000142a:	6161                	addi	sp,sp,80
    8000142c:	8082                	ret

000000008000142e <kvmmap>:
{
    8000142e:	1141                	addi	sp,sp,-16
    80001430:	e406                	sd	ra,8(sp)
    80001432:	e022                	sd	s0,0(sp)
    80001434:	0800                	addi	s0,sp,16
  if(mappages(kernel_pagetable, va, sz, pa, perm) != 0)
    80001436:	8736                	mv	a4,a3
    80001438:	86ae                	mv	a3,a1
    8000143a:	85aa                	mv	a1,a0
    8000143c:	0002f797          	auipc	a5,0x2f
    80001440:	bf478793          	addi	a5,a5,-1036 # 80030030 <kernel_pagetable>
    80001444:	6388                	ld	a0,0(a5)
    80001446:	00000097          	auipc	ra,0x0
    8000144a:	f5c080e7          	jalr	-164(ra) # 800013a2 <mappages>
    8000144e:	e509                	bnez	a0,80001458 <kvmmap+0x2a>
}
    80001450:	60a2                	ld	ra,8(sp)
    80001452:	6402                	ld	s0,0(sp)
    80001454:	0141                	addi	sp,sp,16
    80001456:	8082                	ret
    panic("kvmmap");
    80001458:	00007517          	auipc	a0,0x7
    8000145c:	ee050513          	addi	a0,a0,-288 # 80008338 <userret+0x2a8>
    80001460:	fffff097          	auipc	ra,0xfffff
    80001464:	11e080e7          	jalr	286(ra) # 8000057e <panic>

0000000080001468 <kvminit>:
{
    80001468:	1101                	addi	sp,sp,-32
    8000146a:	ec06                	sd	ra,24(sp)
    8000146c:	e822                	sd	s0,16(sp)
    8000146e:	e426                	sd	s1,8(sp)
    80001470:	1000                	addi	s0,sp,32
  kernel_pagetable = (pagetable_t) kalloc();
    80001472:	fffff097          	auipc	ra,0xfffff
    80001476:	582080e7          	jalr	1410(ra) # 800009f4 <kalloc>
    8000147a:	0002f797          	auipc	a5,0x2f
    8000147e:	baa7bb23          	sd	a0,-1098(a5) # 80030030 <kernel_pagetable>
  memset(kernel_pagetable, 0, PGSIZE);
    80001482:	6605                	lui	a2,0x1
    80001484:	4581                	li	a1,0
    80001486:	00000097          	auipc	ra,0x0
    8000148a:	a56080e7          	jalr	-1450(ra) # 80000edc <memset>
  kvmmap(UART0, UART0, PGSIZE, PTE_R | PTE_W);
    8000148e:	4699                	li	a3,6
    80001490:	6605                	lui	a2,0x1
    80001492:	100005b7          	lui	a1,0x10000
    80001496:	10000537          	lui	a0,0x10000
    8000149a:	00000097          	auipc	ra,0x0
    8000149e:	f94080e7          	jalr	-108(ra) # 8000142e <kvmmap>
  kvmmap(VIRTION(0), VIRTION(0), PGSIZE, PTE_R | PTE_W);
    800014a2:	4699                	li	a3,6
    800014a4:	6605                	lui	a2,0x1
    800014a6:	100015b7          	lui	a1,0x10001
    800014aa:	10001537          	lui	a0,0x10001
    800014ae:	00000097          	auipc	ra,0x0
    800014b2:	f80080e7          	jalr	-128(ra) # 8000142e <kvmmap>
  kvmmap(VIRTION(1), VIRTION(1), PGSIZE, PTE_R | PTE_W);
    800014b6:	4699                	li	a3,6
    800014b8:	6605                	lui	a2,0x1
    800014ba:	100025b7          	lui	a1,0x10002
    800014be:	10002537          	lui	a0,0x10002
    800014c2:	00000097          	auipc	ra,0x0
    800014c6:	f6c080e7          	jalr	-148(ra) # 8000142e <kvmmap>
  kvmmap(CLINT, CLINT, 0x10000, PTE_R | PTE_W);
    800014ca:	4699                	li	a3,6
    800014cc:	6641                	lui	a2,0x10
    800014ce:	020005b7          	lui	a1,0x2000
    800014d2:	02000537          	lui	a0,0x2000
    800014d6:	00000097          	auipc	ra,0x0
    800014da:	f58080e7          	jalr	-168(ra) # 8000142e <kvmmap>
  kvmmap(PLIC, PLIC, 0x400000, PTE_R | PTE_W);
    800014de:	4699                	li	a3,6
    800014e0:	00400637          	lui	a2,0x400
    800014e4:	0c0005b7          	lui	a1,0xc000
    800014e8:	0c000537          	lui	a0,0xc000
    800014ec:	00000097          	auipc	ra,0x0
    800014f0:	f42080e7          	jalr	-190(ra) # 8000142e <kvmmap>
  kvmmap(KERNBASE, KERNBASE, (uint64)etext-KERNBASE, PTE_R | PTE_X);
    800014f4:	00008497          	auipc	s1,0x8
    800014f8:	b0c48493          	addi	s1,s1,-1268 # 80009000 <initcode>
    800014fc:	46a9                	li	a3,10
    800014fe:	80008617          	auipc	a2,0x80008
    80001502:	b0260613          	addi	a2,a2,-1278 # 9000 <_entry-0x7fff7000>
    80001506:	4585                	li	a1,1
    80001508:	05fe                	slli	a1,a1,0x1f
    8000150a:	852e                	mv	a0,a1
    8000150c:	00000097          	auipc	ra,0x0
    80001510:	f22080e7          	jalr	-222(ra) # 8000142e <kvmmap>
  kvmmap((uint64)etext, (uint64)etext, PHYSTOP-(uint64)etext, PTE_R | PTE_W);
    80001514:	4699                	li	a3,6
    80001516:	4645                	li	a2,17
    80001518:	066e                	slli	a2,a2,0x1b
    8000151a:	8e05                	sub	a2,a2,s1
    8000151c:	85a6                	mv	a1,s1
    8000151e:	8526                	mv	a0,s1
    80001520:	00000097          	auipc	ra,0x0
    80001524:	f0e080e7          	jalr	-242(ra) # 8000142e <kvmmap>
  kvmmap(TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);
    80001528:	46a9                	li	a3,10
    8000152a:	6605                	lui	a2,0x1
    8000152c:	00007597          	auipc	a1,0x7
    80001530:	ad458593          	addi	a1,a1,-1324 # 80008000 <trampoline>
    80001534:	04000537          	lui	a0,0x4000
    80001538:	157d                	addi	a0,a0,-1
    8000153a:	0532                	slli	a0,a0,0xc
    8000153c:	00000097          	auipc	ra,0x0
    80001540:	ef2080e7          	jalr	-270(ra) # 8000142e <kvmmap>
}
    80001544:	60e2                	ld	ra,24(sp)
    80001546:	6442                	ld	s0,16(sp)
    80001548:	64a2                	ld	s1,8(sp)
    8000154a:	6105                	addi	sp,sp,32
    8000154c:	8082                	ret

000000008000154e <uvmunmap>:
{
    8000154e:	715d                	addi	sp,sp,-80
    80001550:	e486                	sd	ra,72(sp)
    80001552:	e0a2                	sd	s0,64(sp)
    80001554:	fc26                	sd	s1,56(sp)
    80001556:	f84a                	sd	s2,48(sp)
    80001558:	f44e                	sd	s3,40(sp)
    8000155a:	f052                	sd	s4,32(sp)
    8000155c:	ec56                	sd	s5,24(sp)
    8000155e:	e85a                	sd	s6,16(sp)
    80001560:	e45e                	sd	s7,8(sp)
    80001562:	0880                	addi	s0,sp,80
    80001564:	8a2a                	mv	s4,a0
    80001566:	8ab6                	mv	s5,a3
  a = PGROUNDDOWN(va);
    80001568:	79fd                	lui	s3,0xfffff
    8000156a:	0135f933          	and	s2,a1,s3
  last = PGROUNDDOWN(va + size - 1);
    8000156e:	167d                	addi	a2,a2,-1
    80001570:	962e                	add	a2,a2,a1
    80001572:	013679b3          	and	s3,a2,s3
    if(PTE_FLAGS(*pte) == PTE_V)
    80001576:	4b05                	li	s6,1
    a += PGSIZE;
    80001578:	6b85                	lui	s7,0x1
    8000157a:	a8b1                	j	800015d6 <uvmunmap+0x88>
      panic("uvmunmap: walk");
    8000157c:	00007517          	auipc	a0,0x7
    80001580:	dc450513          	addi	a0,a0,-572 # 80008340 <userret+0x2b0>
    80001584:	fffff097          	auipc	ra,0xfffff
    80001588:	ffa080e7          	jalr	-6(ra) # 8000057e <panic>
      printf("va=%p pte=%p\n", a, *pte);
    8000158c:	862a                	mv	a2,a0
    8000158e:	85ca                	mv	a1,s2
    80001590:	00007517          	auipc	a0,0x7
    80001594:	dc050513          	addi	a0,a0,-576 # 80008350 <userret+0x2c0>
    80001598:	fffff097          	auipc	ra,0xfffff
    8000159c:	040080e7          	jalr	64(ra) # 800005d8 <printf>
      panic("uvmunmap: not mapped");
    800015a0:	00007517          	auipc	a0,0x7
    800015a4:	dc050513          	addi	a0,a0,-576 # 80008360 <userret+0x2d0>
    800015a8:	fffff097          	auipc	ra,0xfffff
    800015ac:	fd6080e7          	jalr	-42(ra) # 8000057e <panic>
      panic("uvmunmap: not a leaf");
    800015b0:	00007517          	auipc	a0,0x7
    800015b4:	dc850513          	addi	a0,a0,-568 # 80008378 <userret+0x2e8>
    800015b8:	fffff097          	auipc	ra,0xfffff
    800015bc:	fc6080e7          	jalr	-58(ra) # 8000057e <panic>
      pa = PTE2PA(*pte);
    800015c0:	8129                	srli	a0,a0,0xa
      kfree((void*)pa);
    800015c2:	0532                	slli	a0,a0,0xc
    800015c4:	fffff097          	auipc	ra,0xfffff
    800015c8:	2e0080e7          	jalr	736(ra) # 800008a4 <kfree>
    *pte = 0;
    800015cc:	0004b023          	sd	zero,0(s1)
    if(a == last)
    800015d0:	03390763          	beq	s2,s3,800015fe <uvmunmap+0xb0>
    a += PGSIZE;
    800015d4:	995e                	add	s2,s2,s7
    if((pte = walk(pagetable, a, 0)) == 0)
    800015d6:	4601                	li	a2,0
    800015d8:	85ca                	mv	a1,s2
    800015da:	8552                	mv	a0,s4
    800015dc:	00000097          	auipc	ra,0x0
    800015e0:	bec080e7          	jalr	-1044(ra) # 800011c8 <walk>
    800015e4:	84aa                	mv	s1,a0
    800015e6:	d959                	beqz	a0,8000157c <uvmunmap+0x2e>
    if((*pte & PTE_V) == 0){
    800015e8:	6108                	ld	a0,0(a0)
    800015ea:	00157793          	andi	a5,a0,1
    800015ee:	dfd9                	beqz	a5,8000158c <uvmunmap+0x3e>
    if(PTE_FLAGS(*pte) == PTE_V)
    800015f0:	3ff57793          	andi	a5,a0,1023
    800015f4:	fb678ee3          	beq	a5,s6,800015b0 <uvmunmap+0x62>
    if(do_free){
    800015f8:	fc0a8ae3          	beqz	s5,800015cc <uvmunmap+0x7e>
    800015fc:	b7d1                	j	800015c0 <uvmunmap+0x72>
}
    800015fe:	60a6                	ld	ra,72(sp)
    80001600:	6406                	ld	s0,64(sp)
    80001602:	74e2                	ld	s1,56(sp)
    80001604:	7942                	ld	s2,48(sp)
    80001606:	79a2                	ld	s3,40(sp)
    80001608:	7a02                	ld	s4,32(sp)
    8000160a:	6ae2                	ld	s5,24(sp)
    8000160c:	6b42                	ld	s6,16(sp)
    8000160e:	6ba2                	ld	s7,8(sp)
    80001610:	6161                	addi	sp,sp,80
    80001612:	8082                	ret

0000000080001614 <uvmcreate>:
{
    80001614:	1101                	addi	sp,sp,-32
    80001616:	ec06                	sd	ra,24(sp)
    80001618:	e822                	sd	s0,16(sp)
    8000161a:	e426                	sd	s1,8(sp)
    8000161c:	1000                	addi	s0,sp,32
  pagetable = (pagetable_t) kalloc();
    8000161e:	fffff097          	auipc	ra,0xfffff
    80001622:	3d6080e7          	jalr	982(ra) # 800009f4 <kalloc>
  if(pagetable == 0)
    80001626:	cd11                	beqz	a0,80001642 <uvmcreate+0x2e>
    80001628:	84aa                	mv	s1,a0
  memset(pagetable, 0, PGSIZE);
    8000162a:	6605                	lui	a2,0x1
    8000162c:	4581                	li	a1,0
    8000162e:	00000097          	auipc	ra,0x0
    80001632:	8ae080e7          	jalr	-1874(ra) # 80000edc <memset>
}
    80001636:	8526                	mv	a0,s1
    80001638:	60e2                	ld	ra,24(sp)
    8000163a:	6442                	ld	s0,16(sp)
    8000163c:	64a2                	ld	s1,8(sp)
    8000163e:	6105                	addi	sp,sp,32
    80001640:	8082                	ret
    panic("uvmcreate: out of memory");
    80001642:	00007517          	auipc	a0,0x7
    80001646:	d4e50513          	addi	a0,a0,-690 # 80008390 <userret+0x300>
    8000164a:	fffff097          	auipc	ra,0xfffff
    8000164e:	f34080e7          	jalr	-204(ra) # 8000057e <panic>

0000000080001652 <uvminit>:
{
    80001652:	7179                	addi	sp,sp,-48
    80001654:	f406                	sd	ra,40(sp)
    80001656:	f022                	sd	s0,32(sp)
    80001658:	ec26                	sd	s1,24(sp)
    8000165a:	e84a                	sd	s2,16(sp)
    8000165c:	e44e                	sd	s3,8(sp)
    8000165e:	e052                	sd	s4,0(sp)
    80001660:	1800                	addi	s0,sp,48
  if(sz >= PGSIZE)
    80001662:	6785                	lui	a5,0x1
    80001664:	04f67863          	bleu	a5,a2,800016b4 <uvminit+0x62>
    80001668:	8a2a                	mv	s4,a0
    8000166a:	89ae                	mv	s3,a1
    8000166c:	84b2                	mv	s1,a2
  mem = kalloc();
    8000166e:	fffff097          	auipc	ra,0xfffff
    80001672:	386080e7          	jalr	902(ra) # 800009f4 <kalloc>
    80001676:	892a                	mv	s2,a0
  memset(mem, 0, PGSIZE);
    80001678:	6605                	lui	a2,0x1
    8000167a:	4581                	li	a1,0
    8000167c:	00000097          	auipc	ra,0x0
    80001680:	860080e7          	jalr	-1952(ra) # 80000edc <memset>
  mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U);
    80001684:	4779                	li	a4,30
    80001686:	86ca                	mv	a3,s2
    80001688:	6605                	lui	a2,0x1
    8000168a:	4581                	li	a1,0
    8000168c:	8552                	mv	a0,s4
    8000168e:	00000097          	auipc	ra,0x0
    80001692:	d14080e7          	jalr	-748(ra) # 800013a2 <mappages>
  memmove(mem, src, sz);
    80001696:	8626                	mv	a2,s1
    80001698:	85ce                	mv	a1,s3
    8000169a:	854a                	mv	a0,s2
    8000169c:	00000097          	auipc	ra,0x0
    800016a0:	8ac080e7          	jalr	-1876(ra) # 80000f48 <memmove>
}
    800016a4:	70a2                	ld	ra,40(sp)
    800016a6:	7402                	ld	s0,32(sp)
    800016a8:	64e2                	ld	s1,24(sp)
    800016aa:	6942                	ld	s2,16(sp)
    800016ac:	69a2                	ld	s3,8(sp)
    800016ae:	6a02                	ld	s4,0(sp)
    800016b0:	6145                	addi	sp,sp,48
    800016b2:	8082                	ret
    panic("inituvm: more than a page");
    800016b4:	00007517          	auipc	a0,0x7
    800016b8:	cfc50513          	addi	a0,a0,-772 # 800083b0 <userret+0x320>
    800016bc:	fffff097          	auipc	ra,0xfffff
    800016c0:	ec2080e7          	jalr	-318(ra) # 8000057e <panic>

00000000800016c4 <uvmdealloc>:
{
    800016c4:	1101                	addi	sp,sp,-32
    800016c6:	ec06                	sd	ra,24(sp)
    800016c8:	e822                	sd	s0,16(sp)
    800016ca:	e426                	sd	s1,8(sp)
    800016cc:	1000                	addi	s0,sp,32
    return oldsz;
    800016ce:	84ae                	mv	s1,a1
  if(newsz >= oldsz)
    800016d0:	00b67d63          	bleu	a1,a2,800016ea <uvmdealloc+0x26>
    800016d4:	84b2                	mv	s1,a2
  uint64 newup = PGROUNDUP(newsz);
    800016d6:	6785                	lui	a5,0x1
    800016d8:	17fd                	addi	a5,a5,-1
    800016da:	00f60733          	add	a4,a2,a5
    800016de:	76fd                	lui	a3,0xfffff
    800016e0:	8f75                	and	a4,a4,a3
  if(newup < PGROUNDUP(oldsz))
    800016e2:	97ae                	add	a5,a5,a1
    800016e4:	8ff5                	and	a5,a5,a3
    800016e6:	00f76863          	bltu	a4,a5,800016f6 <uvmdealloc+0x32>
}
    800016ea:	8526                	mv	a0,s1
    800016ec:	60e2                	ld	ra,24(sp)
    800016ee:	6442                	ld	s0,16(sp)
    800016f0:	64a2                	ld	s1,8(sp)
    800016f2:	6105                	addi	sp,sp,32
    800016f4:	8082                	ret
    uvmunmap(pagetable, newup, oldsz - newup, 1);
    800016f6:	4685                	li	a3,1
    800016f8:	40e58633          	sub	a2,a1,a4
    800016fc:	85ba                	mv	a1,a4
    800016fe:	00000097          	auipc	ra,0x0
    80001702:	e50080e7          	jalr	-432(ra) # 8000154e <uvmunmap>
    80001706:	b7d5                	j	800016ea <uvmdealloc+0x26>

0000000080001708 <uvmalloc>:
  if(newsz < oldsz)
    80001708:	0ab66163          	bltu	a2,a1,800017aa <uvmalloc+0xa2>
{
    8000170c:	7139                	addi	sp,sp,-64
    8000170e:	fc06                	sd	ra,56(sp)
    80001710:	f822                	sd	s0,48(sp)
    80001712:	f426                	sd	s1,40(sp)
    80001714:	f04a                	sd	s2,32(sp)
    80001716:	ec4e                	sd	s3,24(sp)
    80001718:	e852                	sd	s4,16(sp)
    8000171a:	e456                	sd	s5,8(sp)
    8000171c:	0080                	addi	s0,sp,64
  oldsz = PGROUNDUP(oldsz);
    8000171e:	6a05                	lui	s4,0x1
    80001720:	1a7d                	addi	s4,s4,-1
    80001722:	95d2                	add	a1,a1,s4
    80001724:	7a7d                	lui	s4,0xfffff
    80001726:	0145fa33          	and	s4,a1,s4
  for(; a < newsz; a += PGSIZE){
    8000172a:	08ca7263          	bleu	a2,s4,800017ae <uvmalloc+0xa6>
    8000172e:	89b2                	mv	s3,a2
    80001730:	8aaa                	mv	s5,a0
  a = oldsz;
    80001732:	8952                	mv	s2,s4
    mem = kalloc();
    80001734:	fffff097          	auipc	ra,0xfffff
    80001738:	2c0080e7          	jalr	704(ra) # 800009f4 <kalloc>
    8000173c:	84aa                	mv	s1,a0
    if(mem == 0){
    8000173e:	c51d                	beqz	a0,8000176c <uvmalloc+0x64>
    memset(mem, 0, PGSIZE);
    80001740:	6605                	lui	a2,0x1
    80001742:	4581                	li	a1,0
    80001744:	fffff097          	auipc	ra,0xfffff
    80001748:	798080e7          	jalr	1944(ra) # 80000edc <memset>
    if(mappages(pagetable, a, PGSIZE, (uint64)mem, PTE_W|PTE_X|PTE_R|PTE_U) != 0){
    8000174c:	4779                	li	a4,30
    8000174e:	86a6                	mv	a3,s1
    80001750:	6605                	lui	a2,0x1
    80001752:	85ca                	mv	a1,s2
    80001754:	8556                	mv	a0,s5
    80001756:	00000097          	auipc	ra,0x0
    8000175a:	c4c080e7          	jalr	-948(ra) # 800013a2 <mappages>
    8000175e:	e905                	bnez	a0,8000178e <uvmalloc+0x86>
  for(; a < newsz; a += PGSIZE){
    80001760:	6785                	lui	a5,0x1
    80001762:	993e                	add	s2,s2,a5
    80001764:	fd3968e3          	bltu	s2,s3,80001734 <uvmalloc+0x2c>
  return newsz;
    80001768:	854e                	mv	a0,s3
    8000176a:	a809                	j	8000177c <uvmalloc+0x74>
      uvmdealloc(pagetable, a, oldsz);
    8000176c:	8652                	mv	a2,s4
    8000176e:	85ca                	mv	a1,s2
    80001770:	8556                	mv	a0,s5
    80001772:	00000097          	auipc	ra,0x0
    80001776:	f52080e7          	jalr	-174(ra) # 800016c4 <uvmdealloc>
      return 0;
    8000177a:	4501                	li	a0,0
}
    8000177c:	70e2                	ld	ra,56(sp)
    8000177e:	7442                	ld	s0,48(sp)
    80001780:	74a2                	ld	s1,40(sp)
    80001782:	7902                	ld	s2,32(sp)
    80001784:	69e2                	ld	s3,24(sp)
    80001786:	6a42                	ld	s4,16(sp)
    80001788:	6aa2                	ld	s5,8(sp)
    8000178a:	6121                	addi	sp,sp,64
    8000178c:	8082                	ret
      kfree(mem);
    8000178e:	8526                	mv	a0,s1
    80001790:	fffff097          	auipc	ra,0xfffff
    80001794:	114080e7          	jalr	276(ra) # 800008a4 <kfree>
      uvmdealloc(pagetable, a, oldsz);
    80001798:	8652                	mv	a2,s4
    8000179a:	85ca                	mv	a1,s2
    8000179c:	8556                	mv	a0,s5
    8000179e:	00000097          	auipc	ra,0x0
    800017a2:	f26080e7          	jalr	-218(ra) # 800016c4 <uvmdealloc>
      return 0;
    800017a6:	4501                	li	a0,0
    800017a8:	bfd1                	j	8000177c <uvmalloc+0x74>
    return oldsz;
    800017aa:	852e                	mv	a0,a1
}
    800017ac:	8082                	ret
  return newsz;
    800017ae:	8532                	mv	a0,a2
    800017b0:	b7f1                	j	8000177c <uvmalloc+0x74>

00000000800017b2 <uvmfree>:

// Free user memory pages,
// then free page-table pages.
void
uvmfree(pagetable_t pagetable, uint64 sz)
{
    800017b2:	1101                	addi	sp,sp,-32
    800017b4:	ec06                	sd	ra,24(sp)
    800017b6:	e822                	sd	s0,16(sp)
    800017b8:	e426                	sd	s1,8(sp)
    800017ba:	1000                	addi	s0,sp,32
    800017bc:	84aa                	mv	s1,a0
  uvmunmap(pagetable, 0, sz, 1);
    800017be:	4685                	li	a3,1
    800017c0:	862e                	mv	a2,a1
    800017c2:	4581                	li	a1,0
    800017c4:	00000097          	auipc	ra,0x0
    800017c8:	d8a080e7          	jalr	-630(ra) # 8000154e <uvmunmap>
  freewalk(pagetable);
    800017cc:	8526                	mv	a0,s1
    800017ce:	00000097          	auipc	ra,0x0
    800017d2:	aa0080e7          	jalr	-1376(ra) # 8000126e <freewalk>
}
    800017d6:	60e2                	ld	ra,24(sp)
    800017d8:	6442                	ld	s0,16(sp)
    800017da:	64a2                	ld	s1,8(sp)
    800017dc:	6105                	addi	sp,sp,32
    800017de:	8082                	ret

00000000800017e0 <uvmcopy>:
  pte_t *pte;
  uint64 pa, i;
  uint flags;
  char *mem;

  for(i = 0; i < sz; i += PGSIZE){
    800017e0:	c671                	beqz	a2,800018ac <uvmcopy+0xcc>
{
    800017e2:	715d                	addi	sp,sp,-80
    800017e4:	e486                	sd	ra,72(sp)
    800017e6:	e0a2                	sd	s0,64(sp)
    800017e8:	fc26                	sd	s1,56(sp)
    800017ea:	f84a                	sd	s2,48(sp)
    800017ec:	f44e                	sd	s3,40(sp)
    800017ee:	f052                	sd	s4,32(sp)
    800017f0:	ec56                	sd	s5,24(sp)
    800017f2:	e85a                	sd	s6,16(sp)
    800017f4:	e45e                	sd	s7,8(sp)
    800017f6:	0880                	addi	s0,sp,80
    800017f8:	8ab2                	mv	s5,a2
    800017fa:	8b2e                	mv	s6,a1
    800017fc:	8baa                	mv	s7,a0
  for(i = 0; i < sz; i += PGSIZE){
    800017fe:	4901                	li	s2,0
    if((pte = walk(old, i, 0)) == 0)
    80001800:	4601                	li	a2,0
    80001802:	85ca                	mv	a1,s2
    80001804:	855e                	mv	a0,s7
    80001806:	00000097          	auipc	ra,0x0
    8000180a:	9c2080e7          	jalr	-1598(ra) # 800011c8 <walk>
    8000180e:	c531                	beqz	a0,8000185a <uvmcopy+0x7a>
      panic("uvmcopy: pte should exist");
    if((*pte & PTE_V) == 0)
    80001810:	6118                	ld	a4,0(a0)
    80001812:	00177793          	andi	a5,a4,1
    80001816:	cbb1                	beqz	a5,8000186a <uvmcopy+0x8a>
      panic("uvmcopy: page not present");
    pa = PTE2PA(*pte);
    80001818:	00a75593          	srli	a1,a4,0xa
    8000181c:	00c59993          	slli	s3,a1,0xc
    flags = PTE_FLAGS(*pte);
    80001820:	3ff77493          	andi	s1,a4,1023
    if((mem = kalloc()) == 0)
    80001824:	fffff097          	auipc	ra,0xfffff
    80001828:	1d0080e7          	jalr	464(ra) # 800009f4 <kalloc>
    8000182c:	8a2a                	mv	s4,a0
    8000182e:	c939                	beqz	a0,80001884 <uvmcopy+0xa4>
      goto err;
    memmove(mem, (char*)pa, PGSIZE);
    80001830:	6605                	lui	a2,0x1
    80001832:	85ce                	mv	a1,s3
    80001834:	fffff097          	auipc	ra,0xfffff
    80001838:	714080e7          	jalr	1812(ra) # 80000f48 <memmove>
    if(mappages(new, i, PGSIZE, (uint64)mem, flags) != 0){
    8000183c:	8726                	mv	a4,s1
    8000183e:	86d2                	mv	a3,s4
    80001840:	6605                	lui	a2,0x1
    80001842:	85ca                	mv	a1,s2
    80001844:	855a                	mv	a0,s6
    80001846:	00000097          	auipc	ra,0x0
    8000184a:	b5c080e7          	jalr	-1188(ra) # 800013a2 <mappages>
    8000184e:	e515                	bnez	a0,8000187a <uvmcopy+0x9a>
  for(i = 0; i < sz; i += PGSIZE){
    80001850:	6785                	lui	a5,0x1
    80001852:	993e                	add	s2,s2,a5
    80001854:	fb5966e3          	bltu	s2,s5,80001800 <uvmcopy+0x20>
    80001858:	a83d                	j	80001896 <uvmcopy+0xb6>
      panic("uvmcopy: pte should exist");
    8000185a:	00007517          	auipc	a0,0x7
    8000185e:	b7650513          	addi	a0,a0,-1162 # 800083d0 <userret+0x340>
    80001862:	fffff097          	auipc	ra,0xfffff
    80001866:	d1c080e7          	jalr	-740(ra) # 8000057e <panic>
      panic("uvmcopy: page not present");
    8000186a:	00007517          	auipc	a0,0x7
    8000186e:	b8650513          	addi	a0,a0,-1146 # 800083f0 <userret+0x360>
    80001872:	fffff097          	auipc	ra,0xfffff
    80001876:	d0c080e7          	jalr	-756(ra) # 8000057e <panic>
      kfree(mem);
    8000187a:	8552                	mv	a0,s4
    8000187c:	fffff097          	auipc	ra,0xfffff
    80001880:	028080e7          	jalr	40(ra) # 800008a4 <kfree>
    }
  }
  return 0;

 err:
  uvmunmap(new, 0, i, 1);
    80001884:	4685                	li	a3,1
    80001886:	864a                	mv	a2,s2
    80001888:	4581                	li	a1,0
    8000188a:	855a                	mv	a0,s6
    8000188c:	00000097          	auipc	ra,0x0
    80001890:	cc2080e7          	jalr	-830(ra) # 8000154e <uvmunmap>
  return -1;
    80001894:	557d                	li	a0,-1
}
    80001896:	60a6                	ld	ra,72(sp)
    80001898:	6406                	ld	s0,64(sp)
    8000189a:	74e2                	ld	s1,56(sp)
    8000189c:	7942                	ld	s2,48(sp)
    8000189e:	79a2                	ld	s3,40(sp)
    800018a0:	7a02                	ld	s4,32(sp)
    800018a2:	6ae2                	ld	s5,24(sp)
    800018a4:	6b42                	ld	s6,16(sp)
    800018a6:	6ba2                	ld	s7,8(sp)
    800018a8:	6161                	addi	sp,sp,80
    800018aa:	8082                	ret
  return 0;
    800018ac:	4501                	li	a0,0
}
    800018ae:	8082                	ret

00000000800018b0 <uvmclear>:

// mark a PTE invalid for user access.
// used by exec for the user stack guard page.
void
uvmclear(pagetable_t pagetable, uint64 va)
{
    800018b0:	1141                	addi	sp,sp,-16
    800018b2:	e406                	sd	ra,8(sp)
    800018b4:	e022                	sd	s0,0(sp)
    800018b6:	0800                	addi	s0,sp,16
  pte_t *pte;
  
  pte = walk(pagetable, va, 0);
    800018b8:	4601                	li	a2,0
    800018ba:	00000097          	auipc	ra,0x0
    800018be:	90e080e7          	jalr	-1778(ra) # 800011c8 <walk>
  if(pte == 0)
    800018c2:	c901                	beqz	a0,800018d2 <uvmclear+0x22>
    panic("uvmclear");
  *pte &= ~PTE_U;
    800018c4:	611c                	ld	a5,0(a0)
    800018c6:	9bbd                	andi	a5,a5,-17
    800018c8:	e11c                	sd	a5,0(a0)
}
    800018ca:	60a2                	ld	ra,8(sp)
    800018cc:	6402                	ld	s0,0(sp)
    800018ce:	0141                	addi	sp,sp,16
    800018d0:	8082                	ret
    panic("uvmclear");
    800018d2:	00007517          	auipc	a0,0x7
    800018d6:	b3e50513          	addi	a0,a0,-1218 # 80008410 <userret+0x380>
    800018da:	fffff097          	auipc	ra,0xfffff
    800018de:	ca4080e7          	jalr	-860(ra) # 8000057e <panic>

00000000800018e2 <copyout>:
int
copyout(pagetable_t pagetable, uint64 dstva, char *src, uint64 len)
{
  uint64 n, va0, pa0;

  while(len > 0){
    800018e2:	c6bd                	beqz	a3,80001950 <copyout+0x6e>
{
    800018e4:	715d                	addi	sp,sp,-80
    800018e6:	e486                	sd	ra,72(sp)
    800018e8:	e0a2                	sd	s0,64(sp)
    800018ea:	fc26                	sd	s1,56(sp)
    800018ec:	f84a                	sd	s2,48(sp)
    800018ee:	f44e                	sd	s3,40(sp)
    800018f0:	f052                	sd	s4,32(sp)
    800018f2:	ec56                	sd	s5,24(sp)
    800018f4:	e85a                	sd	s6,16(sp)
    800018f6:	e45e                	sd	s7,8(sp)
    800018f8:	e062                	sd	s8,0(sp)
    800018fa:	0880                	addi	s0,sp,80
    800018fc:	8baa                	mv	s7,a0
    800018fe:	8a2e                	mv	s4,a1
    80001900:	8ab2                	mv	s5,a2
    80001902:	89b6                	mv	s3,a3
    va0 = PGROUNDDOWN(dstva);
    80001904:	7c7d                	lui	s8,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (dstva - va0);
    80001906:	6b05                	lui	s6,0x1
    80001908:	a015                	j	8000192c <copyout+0x4a>
    if(n > len)
      n = len;
    memmove((void *)(pa0 + (dstva - va0)), src, n);
    8000190a:	9552                	add	a0,a0,s4
    8000190c:	0004861b          	sext.w	a2,s1
    80001910:	85d6                	mv	a1,s5
    80001912:	41250533          	sub	a0,a0,s2
    80001916:	fffff097          	auipc	ra,0xfffff
    8000191a:	632080e7          	jalr	1586(ra) # 80000f48 <memmove>

    len -= n;
    8000191e:	409989b3          	sub	s3,s3,s1
    src += n;
    80001922:	9aa6                	add	s5,s5,s1
    dstva = va0 + PGSIZE;
    80001924:	01690a33          	add	s4,s2,s6
  while(len > 0){
    80001928:	02098263          	beqz	s3,8000194c <copyout+0x6a>
    va0 = PGROUNDDOWN(dstva);
    8000192c:	018a7933          	and	s2,s4,s8
    pa0 = walkaddr(pagetable, va0);
    80001930:	85ca                	mv	a1,s2
    80001932:	855e                	mv	a0,s7
    80001934:	00000097          	auipc	ra,0x0
    80001938:	9ca080e7          	jalr	-1590(ra) # 800012fe <walkaddr>
    if(pa0 == 0)
    8000193c:	cd01                	beqz	a0,80001954 <copyout+0x72>
    n = PGSIZE - (dstva - va0);
    8000193e:	414904b3          	sub	s1,s2,s4
    80001942:	94da                	add	s1,s1,s6
    if(n > len)
    80001944:	fc99f3e3          	bleu	s1,s3,8000190a <copyout+0x28>
    80001948:	84ce                	mv	s1,s3
    8000194a:	b7c1                	j	8000190a <copyout+0x28>
  }
  return 0;
    8000194c:	4501                	li	a0,0
    8000194e:	a021                	j	80001956 <copyout+0x74>
    80001950:	4501                	li	a0,0
}
    80001952:	8082                	ret
      return -1;
    80001954:	557d                	li	a0,-1
}
    80001956:	60a6                	ld	ra,72(sp)
    80001958:	6406                	ld	s0,64(sp)
    8000195a:	74e2                	ld	s1,56(sp)
    8000195c:	7942                	ld	s2,48(sp)
    8000195e:	79a2                	ld	s3,40(sp)
    80001960:	7a02                	ld	s4,32(sp)
    80001962:	6ae2                	ld	s5,24(sp)
    80001964:	6b42                	ld	s6,16(sp)
    80001966:	6ba2                	ld	s7,8(sp)
    80001968:	6c02                	ld	s8,0(sp)
    8000196a:	6161                	addi	sp,sp,80
    8000196c:	8082                	ret

000000008000196e <copyin>:
int
copyin(pagetable_t pagetable, char *dst, uint64 srcva, uint64 len)
{
  uint64 n, va0, pa0;

  while(len > 0){
    8000196e:	caa5                	beqz	a3,800019de <copyin+0x70>
{
    80001970:	715d                	addi	sp,sp,-80
    80001972:	e486                	sd	ra,72(sp)
    80001974:	e0a2                	sd	s0,64(sp)
    80001976:	fc26                	sd	s1,56(sp)
    80001978:	f84a                	sd	s2,48(sp)
    8000197a:	f44e                	sd	s3,40(sp)
    8000197c:	f052                	sd	s4,32(sp)
    8000197e:	ec56                	sd	s5,24(sp)
    80001980:	e85a                	sd	s6,16(sp)
    80001982:	e45e                	sd	s7,8(sp)
    80001984:	e062                	sd	s8,0(sp)
    80001986:	0880                	addi	s0,sp,80
    80001988:	8baa                	mv	s7,a0
    8000198a:	8aae                	mv	s5,a1
    8000198c:	8a32                	mv	s4,a2
    8000198e:	89b6                	mv	s3,a3
    va0 = PGROUNDDOWN(srcva);
    80001990:	7c7d                	lui	s8,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (srcva - va0);
    80001992:	6b05                	lui	s6,0x1
    80001994:	a01d                	j	800019ba <copyin+0x4c>
    if(n > len)
      n = len;
    memmove(dst, (void *)(pa0 + (srcva - va0)), n);
    80001996:	014505b3          	add	a1,a0,s4
    8000199a:	0004861b          	sext.w	a2,s1
    8000199e:	412585b3          	sub	a1,a1,s2
    800019a2:	8556                	mv	a0,s5
    800019a4:	fffff097          	auipc	ra,0xfffff
    800019a8:	5a4080e7          	jalr	1444(ra) # 80000f48 <memmove>

    len -= n;
    800019ac:	409989b3          	sub	s3,s3,s1
    dst += n;
    800019b0:	9aa6                	add	s5,s5,s1
    srcva = va0 + PGSIZE;
    800019b2:	01690a33          	add	s4,s2,s6
  while(len > 0){
    800019b6:	02098263          	beqz	s3,800019da <copyin+0x6c>
    va0 = PGROUNDDOWN(srcva);
    800019ba:	018a7933          	and	s2,s4,s8
    pa0 = walkaddr(pagetable, va0);
    800019be:	85ca                	mv	a1,s2
    800019c0:	855e                	mv	a0,s7
    800019c2:	00000097          	auipc	ra,0x0
    800019c6:	93c080e7          	jalr	-1732(ra) # 800012fe <walkaddr>
    if(pa0 == 0)
    800019ca:	cd01                	beqz	a0,800019e2 <copyin+0x74>
    n = PGSIZE - (srcva - va0);
    800019cc:	414904b3          	sub	s1,s2,s4
    800019d0:	94da                	add	s1,s1,s6
    if(n > len)
    800019d2:	fc99f2e3          	bleu	s1,s3,80001996 <copyin+0x28>
    800019d6:	84ce                	mv	s1,s3
    800019d8:	bf7d                	j	80001996 <copyin+0x28>
  }
  return 0;
    800019da:	4501                	li	a0,0
    800019dc:	a021                	j	800019e4 <copyin+0x76>
    800019de:	4501                	li	a0,0
}
    800019e0:	8082                	ret
      return -1;
    800019e2:	557d                	li	a0,-1
}
    800019e4:	60a6                	ld	ra,72(sp)
    800019e6:	6406                	ld	s0,64(sp)
    800019e8:	74e2                	ld	s1,56(sp)
    800019ea:	7942                	ld	s2,48(sp)
    800019ec:	79a2                	ld	s3,40(sp)
    800019ee:	7a02                	ld	s4,32(sp)
    800019f0:	6ae2                	ld	s5,24(sp)
    800019f2:	6b42                	ld	s6,16(sp)
    800019f4:	6ba2                	ld	s7,8(sp)
    800019f6:	6c02                	ld	s8,0(sp)
    800019f8:	6161                	addi	sp,sp,80
    800019fa:	8082                	ret

00000000800019fc <copyinstr>:
copyinstr(pagetable_t pagetable, char *dst, uint64 srcva, uint64 max)
{
  uint64 n, va0, pa0;
  int got_null = 0;

  while(got_null == 0 && max > 0){
    800019fc:	ced5                	beqz	a3,80001ab8 <copyinstr+0xbc>
{
    800019fe:	715d                	addi	sp,sp,-80
    80001a00:	e486                	sd	ra,72(sp)
    80001a02:	e0a2                	sd	s0,64(sp)
    80001a04:	fc26                	sd	s1,56(sp)
    80001a06:	f84a                	sd	s2,48(sp)
    80001a08:	f44e                	sd	s3,40(sp)
    80001a0a:	f052                	sd	s4,32(sp)
    80001a0c:	ec56                	sd	s5,24(sp)
    80001a0e:	e85a                	sd	s6,16(sp)
    80001a10:	e45e                	sd	s7,8(sp)
    80001a12:	e062                	sd	s8,0(sp)
    80001a14:	0880                	addi	s0,sp,80
    80001a16:	8aaa                	mv	s5,a0
    80001a18:	84ae                	mv	s1,a1
    80001a1a:	8c32                	mv	s8,a2
    80001a1c:	8bb6                	mv	s7,a3
    va0 = PGROUNDDOWN(srcva);
    80001a1e:	7a7d                	lui	s4,0xfffff
    pa0 = walkaddr(pagetable, va0);
    if(pa0 == 0)
      return -1;
    n = PGSIZE - (srcva - va0);
    80001a20:	6985                	lui	s3,0x1
    80001a22:	4b05                	li	s6,1
    80001a24:	a801                	j	80001a34 <copyinstr+0x38>
    if(n > max)
      n = max;

    char *p = (char *) (pa0 + (srcva - va0));
    while(n > 0){
      if(*p == '\0'){
    80001a26:	87a6                	mv	a5,s1
    80001a28:	a085                	j	80001a88 <copyinstr+0x8c>
        *dst = *p;
      }
      --n;
      --max;
      p++;
      dst++;
    80001a2a:	84b2                	mv	s1,a2
    }

    srcva = va0 + PGSIZE;
    80001a2c:	01390c33          	add	s8,s2,s3
  while(got_null == 0 && max > 0){
    80001a30:	080b8063          	beqz	s7,80001ab0 <copyinstr+0xb4>
    va0 = PGROUNDDOWN(srcva);
    80001a34:	014c7933          	and	s2,s8,s4
    pa0 = walkaddr(pagetable, va0);
    80001a38:	85ca                	mv	a1,s2
    80001a3a:	8556                	mv	a0,s5
    80001a3c:	00000097          	auipc	ra,0x0
    80001a40:	8c2080e7          	jalr	-1854(ra) # 800012fe <walkaddr>
    if(pa0 == 0)
    80001a44:	c925                	beqz	a0,80001ab4 <copyinstr+0xb8>
    n = PGSIZE - (srcva - va0);
    80001a46:	41890633          	sub	a2,s2,s8
    80001a4a:	964e                	add	a2,a2,s3
    if(n > max)
    80001a4c:	00cbf363          	bleu	a2,s7,80001a52 <copyinstr+0x56>
    80001a50:	865e                	mv	a2,s7
    char *p = (char *) (pa0 + (srcva - va0));
    80001a52:	9562                	add	a0,a0,s8
    80001a54:	41250533          	sub	a0,a0,s2
    while(n > 0){
    80001a58:	da71                	beqz	a2,80001a2c <copyinstr+0x30>
      if(*p == '\0'){
    80001a5a:	00054703          	lbu	a4,0(a0)
    80001a5e:	d761                	beqz	a4,80001a26 <copyinstr+0x2a>
    80001a60:	9626                	add	a2,a2,s1
    80001a62:	87a6                	mv	a5,s1
    80001a64:	1bfd                	addi	s7,s7,-1
    80001a66:	009b86b3          	add	a3,s7,s1
    80001a6a:	409b04b3          	sub	s1,s6,s1
    80001a6e:	94aa                	add	s1,s1,a0
        *dst = *p;
    80001a70:	00e78023          	sb	a4,0(a5) # 1000 <_entry-0x7ffff000>
      --max;
    80001a74:	40f68bb3          	sub	s7,a3,a5
      p++;
    80001a78:	00f48733          	add	a4,s1,a5
      dst++;
    80001a7c:	0785                	addi	a5,a5,1
    while(n > 0){
    80001a7e:	faf606e3          	beq	a2,a5,80001a2a <copyinstr+0x2e>
      if(*p == '\0'){
    80001a82:	00074703          	lbu	a4,0(a4)
    80001a86:	f76d                	bnez	a4,80001a70 <copyinstr+0x74>
        *dst = '\0';
    80001a88:	00078023          	sb	zero,0(a5)
    80001a8c:	4785                	li	a5,1
  }
  if(got_null){
    80001a8e:	0017b513          	seqz	a0,a5
    80001a92:	40a0053b          	negw	a0,a0
    80001a96:	2501                	sext.w	a0,a0
    return 0;
  } else {
    return -1;
  }
}
    80001a98:	60a6                	ld	ra,72(sp)
    80001a9a:	6406                	ld	s0,64(sp)
    80001a9c:	74e2                	ld	s1,56(sp)
    80001a9e:	7942                	ld	s2,48(sp)
    80001aa0:	79a2                	ld	s3,40(sp)
    80001aa2:	7a02                	ld	s4,32(sp)
    80001aa4:	6ae2                	ld	s5,24(sp)
    80001aa6:	6b42                	ld	s6,16(sp)
    80001aa8:	6ba2                	ld	s7,8(sp)
    80001aaa:	6c02                	ld	s8,0(sp)
    80001aac:	6161                	addi	sp,sp,80
    80001aae:	8082                	ret
    80001ab0:	4781                	li	a5,0
    80001ab2:	bff1                	j	80001a8e <copyinstr+0x92>
      return -1;
    80001ab4:	557d                	li	a0,-1
    80001ab6:	b7cd                	j	80001a98 <copyinstr+0x9c>
  int got_null = 0;
    80001ab8:	4781                	li	a5,0
  if(got_null){
    80001aba:	0017b513          	seqz	a0,a5
    80001abe:	40a0053b          	negw	a0,a0
    80001ac2:	2501                	sext.w	a0,a0
}
    80001ac4:	8082                	ret

0000000080001ac6 <wakeup1>:

// Wake up p if it is sleeping in wait(); used by exit().
// Caller must hold p->lock.
static void
wakeup1(struct proc *p)
{
    80001ac6:	1101                	addi	sp,sp,-32
    80001ac8:	ec06                	sd	ra,24(sp)
    80001aca:	e822                	sd	s0,16(sp)
    80001acc:	e426                	sd	s1,8(sp)
    80001ace:	1000                	addi	s0,sp,32
    80001ad0:	84aa                	mv	s1,a0
  if(!holding(&p->lock))
    80001ad2:	fffff097          	auipc	ra,0xfffff
    80001ad6:	134080e7          	jalr	308(ra) # 80000c06 <holding>
    80001ada:	c909                	beqz	a0,80001aec <wakeup1+0x26>
    panic("wakeup1");
  if(p->chan == p && p->state == SLEEPING) {
    80001adc:	789c                	ld	a5,48(s1)
    80001ade:	00978f63          	beq	a5,s1,80001afc <wakeup1+0x36>
    p->state = RUNNABLE;
  }
}
    80001ae2:	60e2                	ld	ra,24(sp)
    80001ae4:	6442                	ld	s0,16(sp)
    80001ae6:	64a2                	ld	s1,8(sp)
    80001ae8:	6105                	addi	sp,sp,32
    80001aea:	8082                	ret
    panic("wakeup1");
    80001aec:	00007517          	auipc	a0,0x7
    80001af0:	93450513          	addi	a0,a0,-1740 # 80008420 <userret+0x390>
    80001af4:	fffff097          	auipc	ra,0xfffff
    80001af8:	a8a080e7          	jalr	-1398(ra) # 8000057e <panic>
  if(p->chan == p && p->state == SLEEPING) {
    80001afc:	5098                	lw	a4,32(s1)
    80001afe:	4785                	li	a5,1
    80001b00:	fef711e3          	bne	a4,a5,80001ae2 <wakeup1+0x1c>
    p->state = RUNNABLE;
    80001b04:	4789                	li	a5,2
    80001b06:	d09c                	sw	a5,32(s1)
}
    80001b08:	bfe9                	j	80001ae2 <wakeup1+0x1c>

0000000080001b0a <procinit>:
{
    80001b0a:	715d                	addi	sp,sp,-80
    80001b0c:	e486                	sd	ra,72(sp)
    80001b0e:	e0a2                	sd	s0,64(sp)
    80001b10:	fc26                	sd	s1,56(sp)
    80001b12:	f84a                	sd	s2,48(sp)
    80001b14:	f44e                	sd	s3,40(sp)
    80001b16:	f052                	sd	s4,32(sp)
    80001b18:	ec56                	sd	s5,24(sp)
    80001b1a:	e85a                	sd	s6,16(sp)
    80001b1c:	e45e                	sd	s7,8(sp)
    80001b1e:	0880                	addi	s0,sp,80
  initlock(&pid_lock, "nextpid");
    80001b20:	00007597          	auipc	a1,0x7
    80001b24:	90858593          	addi	a1,a1,-1784 # 80008428 <userret+0x398>
    80001b28:	00013517          	auipc	a0,0x13
    80001b2c:	e3050513          	addi	a0,a0,-464 # 80014958 <pid_lock>
    80001b30:	fffff097          	auipc	ra,0xfffff
    80001b34:	fc6080e7          	jalr	-58(ra) # 80000af6 <initlock>
  for(p = proc; p < &proc[NPROC]; p++) {
    80001b38:	00013917          	auipc	s2,0x13
    80001b3c:	24090913          	addi	s2,s2,576 # 80014d78 <proc>
      initlock(&p->lock, "proc");
    80001b40:	00007b97          	auipc	s7,0x7
    80001b44:	8f0b8b93          	addi	s7,s7,-1808 # 80008430 <userret+0x3a0>
      uint64 va = KSTACK((int) (p - proc));
    80001b48:	8b4a                	mv	s6,s2
    80001b4a:	00007a97          	auipc	s5,0x7
    80001b4e:	086a8a93          	addi	s5,s5,134 # 80008bd0 <syscalls+0xb8>
    80001b52:	040009b7          	lui	s3,0x4000
    80001b56:	19fd                	addi	s3,s3,-1
    80001b58:	09b2                	slli	s3,s3,0xc
  for(p = proc; p < &proc[NPROC]; p++) {
    80001b5a:	00019a17          	auipc	s4,0x19
    80001b5e:	e1ea0a13          	addi	s4,s4,-482 # 8001a978 <tickslock>
      initlock(&p->lock, "proc");
    80001b62:	85de                	mv	a1,s7
    80001b64:	854a                	mv	a0,s2
    80001b66:	fffff097          	auipc	ra,0xfffff
    80001b6a:	f90080e7          	jalr	-112(ra) # 80000af6 <initlock>
      char *pa = kalloc();
    80001b6e:	fffff097          	auipc	ra,0xfffff
    80001b72:	e86080e7          	jalr	-378(ra) # 800009f4 <kalloc>
    80001b76:	85aa                	mv	a1,a0
      if(pa == 0)
    80001b78:	c929                	beqz	a0,80001bca <procinit+0xc0>
      uint64 va = KSTACK((int) (p - proc));
    80001b7a:	416904b3          	sub	s1,s2,s6
    80001b7e:	8491                	srai	s1,s1,0x4
    80001b80:	000ab783          	ld	a5,0(s5)
    80001b84:	02f484b3          	mul	s1,s1,a5
    80001b88:	2485                	addiw	s1,s1,1
    80001b8a:	00d4949b          	slliw	s1,s1,0xd
    80001b8e:	409984b3          	sub	s1,s3,s1
      kvmmap(va, (uint64)pa, PGSIZE, PTE_R | PTE_W);
    80001b92:	4699                	li	a3,6
    80001b94:	6605                	lui	a2,0x1
    80001b96:	8526                	mv	a0,s1
    80001b98:	00000097          	auipc	ra,0x0
    80001b9c:	896080e7          	jalr	-1898(ra) # 8000142e <kvmmap>
      p->kstack = va;
    80001ba0:	04993423          	sd	s1,72(s2)
  for(p = proc; p < &proc[NPROC]; p++) {
    80001ba4:	17090913          	addi	s2,s2,368
    80001ba8:	fb491de3          	bne	s2,s4,80001b62 <procinit+0x58>
  kvminithart();
    80001bac:	fffff097          	auipc	ra,0xfffff
    80001bb0:	72c080e7          	jalr	1836(ra) # 800012d8 <kvminithart>
}
    80001bb4:	60a6                	ld	ra,72(sp)
    80001bb6:	6406                	ld	s0,64(sp)
    80001bb8:	74e2                	ld	s1,56(sp)
    80001bba:	7942                	ld	s2,48(sp)
    80001bbc:	79a2                	ld	s3,40(sp)
    80001bbe:	7a02                	ld	s4,32(sp)
    80001bc0:	6ae2                	ld	s5,24(sp)
    80001bc2:	6b42                	ld	s6,16(sp)
    80001bc4:	6ba2                	ld	s7,8(sp)
    80001bc6:	6161                	addi	sp,sp,80
    80001bc8:	8082                	ret
        panic("kalloc");
    80001bca:	00007517          	auipc	a0,0x7
    80001bce:	86e50513          	addi	a0,a0,-1938 # 80008438 <userret+0x3a8>
    80001bd2:	fffff097          	auipc	ra,0xfffff
    80001bd6:	9ac080e7          	jalr	-1620(ra) # 8000057e <panic>

0000000080001bda <cpuid>:
{
    80001bda:	1141                	addi	sp,sp,-16
    80001bdc:	e422                	sd	s0,8(sp)
    80001bde:	0800                	addi	s0,sp,16
  asm volatile("mv %0, tp" : "=r" (x) );
    80001be0:	8512                	mv	a0,tp
}
    80001be2:	2501                	sext.w	a0,a0
    80001be4:	6422                	ld	s0,8(sp)
    80001be6:	0141                	addi	sp,sp,16
    80001be8:	8082                	ret

0000000080001bea <mycpu>:
mycpu(void) {
    80001bea:	1141                	addi	sp,sp,-16
    80001bec:	e422                	sd	s0,8(sp)
    80001bee:	0800                	addi	s0,sp,16
    80001bf0:	8792                	mv	a5,tp
  struct cpu *c = &cpus[id];
    80001bf2:	2781                	sext.w	a5,a5
    80001bf4:	079e                	slli	a5,a5,0x7
}
    80001bf6:	00013517          	auipc	a0,0x13
    80001bfa:	d8250513          	addi	a0,a0,-638 # 80014978 <cpus>
    80001bfe:	953e                	add	a0,a0,a5
    80001c00:	6422                	ld	s0,8(sp)
    80001c02:	0141                	addi	sp,sp,16
    80001c04:	8082                	ret

0000000080001c06 <myproc>:
myproc(void) {
    80001c06:	1101                	addi	sp,sp,-32
    80001c08:	ec06                	sd	ra,24(sp)
    80001c0a:	e822                	sd	s0,16(sp)
    80001c0c:	e426                	sd	s1,8(sp)
    80001c0e:	1000                	addi	s0,sp,32
  push_off();
    80001c10:	fffff097          	auipc	ra,0xfffff
    80001c14:	f3e080e7          	jalr	-194(ra) # 80000b4e <push_off>
    80001c18:	8792                	mv	a5,tp
  struct proc *p = c->proc;
    80001c1a:	2781                	sext.w	a5,a5
    80001c1c:	079e                	slli	a5,a5,0x7
    80001c1e:	00013717          	auipc	a4,0x13
    80001c22:	d3a70713          	addi	a4,a4,-710 # 80014958 <pid_lock>
    80001c26:	97ba                	add	a5,a5,a4
    80001c28:	7384                	ld	s1,32(a5)
  pop_off();
    80001c2a:	fffff097          	auipc	ra,0xfffff
    80001c2e:	f70080e7          	jalr	-144(ra) # 80000b9a <pop_off>
}
    80001c32:	8526                	mv	a0,s1
    80001c34:	60e2                	ld	ra,24(sp)
    80001c36:	6442                	ld	s0,16(sp)
    80001c38:	64a2                	ld	s1,8(sp)
    80001c3a:	6105                	addi	sp,sp,32
    80001c3c:	8082                	ret

0000000080001c3e <forkret>:
{
    80001c3e:	1141                	addi	sp,sp,-16
    80001c40:	e406                	sd	ra,8(sp)
    80001c42:	e022                	sd	s0,0(sp)
    80001c44:	0800                	addi	s0,sp,16
  release(&myproc()->lock);
    80001c46:	00000097          	auipc	ra,0x0
    80001c4a:	fc0080e7          	jalr	-64(ra) # 80001c06 <myproc>
    80001c4e:	fffff097          	auipc	ra,0xfffff
    80001c52:	068080e7          	jalr	104(ra) # 80000cb6 <release>
  if (first) {
    80001c56:	00007797          	auipc	a5,0x7
    80001c5a:	40278793          	addi	a5,a5,1026 # 80009058 <first.1765>
    80001c5e:	439c                	lw	a5,0(a5)
    80001c60:	eb89                	bnez	a5,80001c72 <forkret+0x34>
  usertrapret();
    80001c62:	00001097          	auipc	ra,0x1
    80001c66:	be8080e7          	jalr	-1048(ra) # 8000284a <usertrapret>
}
    80001c6a:	60a2                	ld	ra,8(sp)
    80001c6c:	6402                	ld	s0,0(sp)
    80001c6e:	0141                	addi	sp,sp,16
    80001c70:	8082                	ret
    first = 0;
    80001c72:	00007797          	auipc	a5,0x7
    80001c76:	3e07a323          	sw	zero,998(a5) # 80009058 <first.1765>
    fsinit(minor(ROOTDEV));
    80001c7a:	4501                	li	a0,0
    80001c7c:	00002097          	auipc	ra,0x2
    80001c80:	a7e080e7          	jalr	-1410(ra) # 800036fa <fsinit>
    80001c84:	bff9                	j	80001c62 <forkret+0x24>

0000000080001c86 <allocpid>:
allocpid() {
    80001c86:	1101                	addi	sp,sp,-32
    80001c88:	ec06                	sd	ra,24(sp)
    80001c8a:	e822                	sd	s0,16(sp)
    80001c8c:	e426                	sd	s1,8(sp)
    80001c8e:	e04a                	sd	s2,0(sp)
    80001c90:	1000                	addi	s0,sp,32
  acquire(&pid_lock);
    80001c92:	00013917          	auipc	s2,0x13
    80001c96:	cc690913          	addi	s2,s2,-826 # 80014958 <pid_lock>
    80001c9a:	854a                	mv	a0,s2
    80001c9c:	fffff097          	auipc	ra,0xfffff
    80001ca0:	faa080e7          	jalr	-86(ra) # 80000c46 <acquire>
  pid = nextpid;
    80001ca4:	00007797          	auipc	a5,0x7
    80001ca8:	3b878793          	addi	a5,a5,952 # 8000905c <nextpid>
    80001cac:	4384                	lw	s1,0(a5)
  nextpid = nextpid + 1;
    80001cae:	0014871b          	addiw	a4,s1,1
    80001cb2:	c398                	sw	a4,0(a5)
  release(&pid_lock);
    80001cb4:	854a                	mv	a0,s2
    80001cb6:	fffff097          	auipc	ra,0xfffff
    80001cba:	000080e7          	jalr	ra # 80000cb6 <release>
}
    80001cbe:	8526                	mv	a0,s1
    80001cc0:	60e2                	ld	ra,24(sp)
    80001cc2:	6442                	ld	s0,16(sp)
    80001cc4:	64a2                	ld	s1,8(sp)
    80001cc6:	6902                	ld	s2,0(sp)
    80001cc8:	6105                	addi	sp,sp,32
    80001cca:	8082                	ret

0000000080001ccc <proc_pagetable>:
{
    80001ccc:	1101                	addi	sp,sp,-32
    80001cce:	ec06                	sd	ra,24(sp)
    80001cd0:	e822                	sd	s0,16(sp)
    80001cd2:	e426                	sd	s1,8(sp)
    80001cd4:	e04a                	sd	s2,0(sp)
    80001cd6:	1000                	addi	s0,sp,32
    80001cd8:	892a                	mv	s2,a0
  pagetable = uvmcreate();
    80001cda:	00000097          	auipc	ra,0x0
    80001cde:	93a080e7          	jalr	-1734(ra) # 80001614 <uvmcreate>
    80001ce2:	84aa                	mv	s1,a0
  mappages(pagetable, TRAMPOLINE, PGSIZE,
    80001ce4:	4729                	li	a4,10
    80001ce6:	00006697          	auipc	a3,0x6
    80001cea:	31a68693          	addi	a3,a3,794 # 80008000 <trampoline>
    80001cee:	6605                	lui	a2,0x1
    80001cf0:	040005b7          	lui	a1,0x4000
    80001cf4:	15fd                	addi	a1,a1,-1
    80001cf6:	05b2                	slli	a1,a1,0xc
    80001cf8:	fffff097          	auipc	ra,0xfffff
    80001cfc:	6aa080e7          	jalr	1706(ra) # 800013a2 <mappages>
  mappages(pagetable, TRAPFRAME, PGSIZE,
    80001d00:	4719                	li	a4,6
    80001d02:	06093683          	ld	a3,96(s2)
    80001d06:	6605                	lui	a2,0x1
    80001d08:	020005b7          	lui	a1,0x2000
    80001d0c:	15fd                	addi	a1,a1,-1
    80001d0e:	05b6                	slli	a1,a1,0xd
    80001d10:	8526                	mv	a0,s1
    80001d12:	fffff097          	auipc	ra,0xfffff
    80001d16:	690080e7          	jalr	1680(ra) # 800013a2 <mappages>
}
    80001d1a:	8526                	mv	a0,s1
    80001d1c:	60e2                	ld	ra,24(sp)
    80001d1e:	6442                	ld	s0,16(sp)
    80001d20:	64a2                	ld	s1,8(sp)
    80001d22:	6902                	ld	s2,0(sp)
    80001d24:	6105                	addi	sp,sp,32
    80001d26:	8082                	ret

0000000080001d28 <allocproc>:
{
    80001d28:	1101                	addi	sp,sp,-32
    80001d2a:	ec06                	sd	ra,24(sp)
    80001d2c:	e822                	sd	s0,16(sp)
    80001d2e:	e426                	sd	s1,8(sp)
    80001d30:	e04a                	sd	s2,0(sp)
    80001d32:	1000                	addi	s0,sp,32
  for(p = proc; p < &proc[NPROC]; p++) {
    80001d34:	00013497          	auipc	s1,0x13
    80001d38:	04448493          	addi	s1,s1,68 # 80014d78 <proc>
    80001d3c:	00019917          	auipc	s2,0x19
    80001d40:	c3c90913          	addi	s2,s2,-964 # 8001a978 <tickslock>
    acquire(&p->lock);
    80001d44:	8526                	mv	a0,s1
    80001d46:	fffff097          	auipc	ra,0xfffff
    80001d4a:	f00080e7          	jalr	-256(ra) # 80000c46 <acquire>
    if(p->state == UNUSED) {
    80001d4e:	509c                	lw	a5,32(s1)
    80001d50:	cf81                	beqz	a5,80001d68 <allocproc+0x40>
      release(&p->lock);
    80001d52:	8526                	mv	a0,s1
    80001d54:	fffff097          	auipc	ra,0xfffff
    80001d58:	f62080e7          	jalr	-158(ra) # 80000cb6 <release>
  for(p = proc; p < &proc[NPROC]; p++) {
    80001d5c:	17048493          	addi	s1,s1,368
    80001d60:	ff2492e3          	bne	s1,s2,80001d44 <allocproc+0x1c>
  return 0;
    80001d64:	4481                	li	s1,0
    80001d66:	a0a9                	j	80001db0 <allocproc+0x88>
  p->pid = allocpid();
    80001d68:	00000097          	auipc	ra,0x0
    80001d6c:	f1e080e7          	jalr	-226(ra) # 80001c86 <allocpid>
    80001d70:	c0a8                	sw	a0,64(s1)
  if((p->tf = (struct trapframe *)kalloc()) == 0){
    80001d72:	fffff097          	auipc	ra,0xfffff
    80001d76:	c82080e7          	jalr	-894(ra) # 800009f4 <kalloc>
    80001d7a:	892a                	mv	s2,a0
    80001d7c:	f0a8                	sd	a0,96(s1)
    80001d7e:	c121                	beqz	a0,80001dbe <allocproc+0x96>
  p->pagetable = proc_pagetable(p);
    80001d80:	8526                	mv	a0,s1
    80001d82:	00000097          	auipc	ra,0x0
    80001d86:	f4a080e7          	jalr	-182(ra) # 80001ccc <proc_pagetable>
    80001d8a:	eca8                	sd	a0,88(s1)
  memset(&p->context, 0, sizeof p->context);
    80001d8c:	07000613          	li	a2,112
    80001d90:	4581                	li	a1,0
    80001d92:	06848513          	addi	a0,s1,104
    80001d96:	fffff097          	auipc	ra,0xfffff
    80001d9a:	146080e7          	jalr	326(ra) # 80000edc <memset>
  p->context.ra = (uint64)forkret;
    80001d9e:	00000797          	auipc	a5,0x0
    80001da2:	ea078793          	addi	a5,a5,-352 # 80001c3e <forkret>
    80001da6:	f4bc                	sd	a5,104(s1)
  p->context.sp = p->kstack + PGSIZE;
    80001da8:	64bc                	ld	a5,72(s1)
    80001daa:	6705                	lui	a4,0x1
    80001dac:	97ba                	add	a5,a5,a4
    80001dae:	f8bc                	sd	a5,112(s1)
}
    80001db0:	8526                	mv	a0,s1
    80001db2:	60e2                	ld	ra,24(sp)
    80001db4:	6442                	ld	s0,16(sp)
    80001db6:	64a2                	ld	s1,8(sp)
    80001db8:	6902                	ld	s2,0(sp)
    80001dba:	6105                	addi	sp,sp,32
    80001dbc:	8082                	ret
    release(&p->lock);
    80001dbe:	8526                	mv	a0,s1
    80001dc0:	fffff097          	auipc	ra,0xfffff
    80001dc4:	ef6080e7          	jalr	-266(ra) # 80000cb6 <release>
    return 0;
    80001dc8:	84ca                	mv	s1,s2
    80001dca:	b7dd                	j	80001db0 <allocproc+0x88>

0000000080001dcc <proc_freepagetable>:
{
    80001dcc:	1101                	addi	sp,sp,-32
    80001dce:	ec06                	sd	ra,24(sp)
    80001dd0:	e822                	sd	s0,16(sp)
    80001dd2:	e426                	sd	s1,8(sp)
    80001dd4:	e04a                	sd	s2,0(sp)
    80001dd6:	1000                	addi	s0,sp,32
    80001dd8:	84aa                	mv	s1,a0
    80001dda:	892e                	mv	s2,a1
  uvmunmap(pagetable, TRAMPOLINE, PGSIZE, 0);
    80001ddc:	4681                	li	a3,0
    80001dde:	6605                	lui	a2,0x1
    80001de0:	040005b7          	lui	a1,0x4000
    80001de4:	15fd                	addi	a1,a1,-1
    80001de6:	05b2                	slli	a1,a1,0xc
    80001de8:	fffff097          	auipc	ra,0xfffff
    80001dec:	766080e7          	jalr	1894(ra) # 8000154e <uvmunmap>
  uvmunmap(pagetable, TRAPFRAME, PGSIZE, 0);
    80001df0:	4681                	li	a3,0
    80001df2:	6605                	lui	a2,0x1
    80001df4:	020005b7          	lui	a1,0x2000
    80001df8:	15fd                	addi	a1,a1,-1
    80001dfa:	05b6                	slli	a1,a1,0xd
    80001dfc:	8526                	mv	a0,s1
    80001dfe:	fffff097          	auipc	ra,0xfffff
    80001e02:	750080e7          	jalr	1872(ra) # 8000154e <uvmunmap>
  if(sz > 0)
    80001e06:	00091863          	bnez	s2,80001e16 <proc_freepagetable+0x4a>
}
    80001e0a:	60e2                	ld	ra,24(sp)
    80001e0c:	6442                	ld	s0,16(sp)
    80001e0e:	64a2                	ld	s1,8(sp)
    80001e10:	6902                	ld	s2,0(sp)
    80001e12:	6105                	addi	sp,sp,32
    80001e14:	8082                	ret
    uvmfree(pagetable, sz);
    80001e16:	85ca                	mv	a1,s2
    80001e18:	8526                	mv	a0,s1
    80001e1a:	00000097          	auipc	ra,0x0
    80001e1e:	998080e7          	jalr	-1640(ra) # 800017b2 <uvmfree>
}
    80001e22:	b7e5                	j	80001e0a <proc_freepagetable+0x3e>

0000000080001e24 <freeproc>:
{
    80001e24:	1101                	addi	sp,sp,-32
    80001e26:	ec06                	sd	ra,24(sp)
    80001e28:	e822                	sd	s0,16(sp)
    80001e2a:	e426                	sd	s1,8(sp)
    80001e2c:	1000                	addi	s0,sp,32
    80001e2e:	84aa                	mv	s1,a0
  if(p->tf)
    80001e30:	7128                	ld	a0,96(a0)
    80001e32:	c509                	beqz	a0,80001e3c <freeproc+0x18>
    kfree((void*)p->tf);
    80001e34:	fffff097          	auipc	ra,0xfffff
    80001e38:	a70080e7          	jalr	-1424(ra) # 800008a4 <kfree>
  p->tf = 0;
    80001e3c:	0604b023          	sd	zero,96(s1)
  if(p->pagetable)
    80001e40:	6ca8                	ld	a0,88(s1)
    80001e42:	c511                	beqz	a0,80001e4e <freeproc+0x2a>
    proc_freepagetable(p->pagetable, p->sz);
    80001e44:	68ac                	ld	a1,80(s1)
    80001e46:	00000097          	auipc	ra,0x0
    80001e4a:	f86080e7          	jalr	-122(ra) # 80001dcc <proc_freepagetable>
  p->pagetable = 0;
    80001e4e:	0404bc23          	sd	zero,88(s1)
  p->sz = 0;
    80001e52:	0404b823          	sd	zero,80(s1)
  p->pid = 0;
    80001e56:	0404a023          	sw	zero,64(s1)
  p->parent = 0;
    80001e5a:	0204b423          	sd	zero,40(s1)
  p->name[0] = 0;
    80001e5e:	16048023          	sb	zero,352(s1)
  p->chan = 0;
    80001e62:	0204b823          	sd	zero,48(s1)
  p->killed = 0;
    80001e66:	0204ac23          	sw	zero,56(s1)
  p->xstate = 0;
    80001e6a:	0204ae23          	sw	zero,60(s1)
  p->state = UNUSED;
    80001e6e:	0204a023          	sw	zero,32(s1)
}
    80001e72:	60e2                	ld	ra,24(sp)
    80001e74:	6442                	ld	s0,16(sp)
    80001e76:	64a2                	ld	s1,8(sp)
    80001e78:	6105                	addi	sp,sp,32
    80001e7a:	8082                	ret

0000000080001e7c <userinit>:
{
    80001e7c:	1101                	addi	sp,sp,-32
    80001e7e:	ec06                	sd	ra,24(sp)
    80001e80:	e822                	sd	s0,16(sp)
    80001e82:	e426                	sd	s1,8(sp)
    80001e84:	1000                	addi	s0,sp,32
  p = allocproc();
    80001e86:	00000097          	auipc	ra,0x0
    80001e8a:	ea2080e7          	jalr	-350(ra) # 80001d28 <allocproc>
    80001e8e:	84aa                	mv	s1,a0
  initproc = p;
    80001e90:	0002e797          	auipc	a5,0x2e
    80001e94:	1aa7b423          	sd	a0,424(a5) # 80030038 <initproc>
  uvminit(p->pagetable, initcode, sizeof(initcode));
    80001e98:	03300613          	li	a2,51
    80001e9c:	00007597          	auipc	a1,0x7
    80001ea0:	16458593          	addi	a1,a1,356 # 80009000 <initcode>
    80001ea4:	6d28                	ld	a0,88(a0)
    80001ea6:	fffff097          	auipc	ra,0xfffff
    80001eaa:	7ac080e7          	jalr	1964(ra) # 80001652 <uvminit>
  p->sz = PGSIZE;
    80001eae:	6785                	lui	a5,0x1
    80001eb0:	e8bc                	sd	a5,80(s1)
  p->tf->epc = 0;      // user program counter
    80001eb2:	70b8                	ld	a4,96(s1)
    80001eb4:	00073c23          	sd	zero,24(a4) # 1018 <_entry-0x7fffefe8>
  p->tf->sp = PGSIZE;  // user stack pointer
    80001eb8:	70b8                	ld	a4,96(s1)
    80001eba:	fb1c                	sd	a5,48(a4)
  safestrcpy(p->name, "initcode", sizeof(p->name));
    80001ebc:	4641                	li	a2,16
    80001ebe:	00006597          	auipc	a1,0x6
    80001ec2:	58258593          	addi	a1,a1,1410 # 80008440 <userret+0x3b0>
    80001ec6:	16048513          	addi	a0,s1,352
    80001eca:	fffff097          	auipc	ra,0xfffff
    80001ece:	18a080e7          	jalr	394(ra) # 80001054 <safestrcpy>
  p->cwd = namei("/");
    80001ed2:	00006517          	auipc	a0,0x6
    80001ed6:	57e50513          	addi	a0,a0,1406 # 80008450 <userret+0x3c0>
    80001eda:	00002097          	auipc	ra,0x2
    80001ede:	22e080e7          	jalr	558(ra) # 80004108 <namei>
    80001ee2:	14a4bc23          	sd	a0,344(s1)
  p->state = RUNNABLE;
    80001ee6:	4789                	li	a5,2
    80001ee8:	d09c                	sw	a5,32(s1)
  release(&p->lock);
    80001eea:	8526                	mv	a0,s1
    80001eec:	fffff097          	auipc	ra,0xfffff
    80001ef0:	dca080e7          	jalr	-566(ra) # 80000cb6 <release>
}
    80001ef4:	60e2                	ld	ra,24(sp)
    80001ef6:	6442                	ld	s0,16(sp)
    80001ef8:	64a2                	ld	s1,8(sp)
    80001efa:	6105                	addi	sp,sp,32
    80001efc:	8082                	ret

0000000080001efe <growproc>:
{
    80001efe:	1101                	addi	sp,sp,-32
    80001f00:	ec06                	sd	ra,24(sp)
    80001f02:	e822                	sd	s0,16(sp)
    80001f04:	e426                	sd	s1,8(sp)
    80001f06:	e04a                	sd	s2,0(sp)
    80001f08:	1000                	addi	s0,sp,32
    80001f0a:	84aa                	mv	s1,a0
  struct proc *p = myproc();
    80001f0c:	00000097          	auipc	ra,0x0
    80001f10:	cfa080e7          	jalr	-774(ra) # 80001c06 <myproc>
    80001f14:	892a                	mv	s2,a0
  sz = p->sz;
    80001f16:	692c                	ld	a1,80(a0)
    80001f18:	0005851b          	sext.w	a0,a1
  if(n > 0){
    80001f1c:	00904f63          	bgtz	s1,80001f3a <growproc+0x3c>
  } else if(n < 0){
    80001f20:	0204cd63          	bltz	s1,80001f5a <growproc+0x5c>
  p->sz = sz;
    80001f24:	1502                	slli	a0,a0,0x20
    80001f26:	9101                	srli	a0,a0,0x20
    80001f28:	04a93823          	sd	a0,80(s2)
  return 0;
    80001f2c:	4501                	li	a0,0
}
    80001f2e:	60e2                	ld	ra,24(sp)
    80001f30:	6442                	ld	s0,16(sp)
    80001f32:	64a2                	ld	s1,8(sp)
    80001f34:	6902                	ld	s2,0(sp)
    80001f36:	6105                	addi	sp,sp,32
    80001f38:	8082                	ret
    if((sz = uvmalloc(p->pagetable, sz, sz + n)) == 0) {
    80001f3a:	00a4863b          	addw	a2,s1,a0
    80001f3e:	1602                	slli	a2,a2,0x20
    80001f40:	9201                	srli	a2,a2,0x20
    80001f42:	1582                	slli	a1,a1,0x20
    80001f44:	9181                	srli	a1,a1,0x20
    80001f46:	05893503          	ld	a0,88(s2)
    80001f4a:	fffff097          	auipc	ra,0xfffff
    80001f4e:	7be080e7          	jalr	1982(ra) # 80001708 <uvmalloc>
    80001f52:	2501                	sext.w	a0,a0
    80001f54:	f961                	bnez	a0,80001f24 <growproc+0x26>
      return -1;
    80001f56:	557d                	li	a0,-1
    80001f58:	bfd9                	j	80001f2e <growproc+0x30>
    sz = uvmdealloc(p->pagetable, sz, sz + n);
    80001f5a:	00a4863b          	addw	a2,s1,a0
    80001f5e:	1602                	slli	a2,a2,0x20
    80001f60:	9201                	srli	a2,a2,0x20
    80001f62:	1582                	slli	a1,a1,0x20
    80001f64:	9181                	srli	a1,a1,0x20
    80001f66:	05893503          	ld	a0,88(s2)
    80001f6a:	fffff097          	auipc	ra,0xfffff
    80001f6e:	75a080e7          	jalr	1882(ra) # 800016c4 <uvmdealloc>
    80001f72:	2501                	sext.w	a0,a0
    80001f74:	bf45                	j	80001f24 <growproc+0x26>

0000000080001f76 <fork>:
{
    80001f76:	7179                	addi	sp,sp,-48
    80001f78:	f406                	sd	ra,40(sp)
    80001f7a:	f022                	sd	s0,32(sp)
    80001f7c:	ec26                	sd	s1,24(sp)
    80001f7e:	e84a                	sd	s2,16(sp)
    80001f80:	e44e                	sd	s3,8(sp)
    80001f82:	e052                	sd	s4,0(sp)
    80001f84:	1800                	addi	s0,sp,48
  struct proc *p = myproc();
    80001f86:	00000097          	auipc	ra,0x0
    80001f8a:	c80080e7          	jalr	-896(ra) # 80001c06 <myproc>
    80001f8e:	892a                	mv	s2,a0
  if((np = allocproc()) == 0){
    80001f90:	00000097          	auipc	ra,0x0
    80001f94:	d98080e7          	jalr	-616(ra) # 80001d28 <allocproc>
    80001f98:	c175                	beqz	a0,8000207c <fork+0x106>
    80001f9a:	89aa                	mv	s3,a0
  if(uvmcopy(p->pagetable, np->pagetable, p->sz) < 0){
    80001f9c:	05093603          	ld	a2,80(s2)
    80001fa0:	6d2c                	ld	a1,88(a0)
    80001fa2:	05893503          	ld	a0,88(s2)
    80001fa6:	00000097          	auipc	ra,0x0
    80001faa:	83a080e7          	jalr	-1990(ra) # 800017e0 <uvmcopy>
    80001fae:	04054863          	bltz	a0,80001ffe <fork+0x88>
  np->sz = p->sz;
    80001fb2:	05093783          	ld	a5,80(s2)
    80001fb6:	04f9b823          	sd	a5,80(s3) # 4000050 <_entry-0x7bffffb0>
  np->parent = p;
    80001fba:	0329b423          	sd	s2,40(s3)
  *(np->tf) = *(p->tf);
    80001fbe:	06093683          	ld	a3,96(s2)
    80001fc2:	87b6                	mv	a5,a3
    80001fc4:	0609b703          	ld	a4,96(s3)
    80001fc8:	12068693          	addi	a3,a3,288
    80001fcc:	0007b803          	ld	a6,0(a5) # 1000 <_entry-0x7ffff000>
    80001fd0:	6788                	ld	a0,8(a5)
    80001fd2:	6b8c                	ld	a1,16(a5)
    80001fd4:	6f90                	ld	a2,24(a5)
    80001fd6:	01073023          	sd	a6,0(a4)
    80001fda:	e708                	sd	a0,8(a4)
    80001fdc:	eb0c                	sd	a1,16(a4)
    80001fde:	ef10                	sd	a2,24(a4)
    80001fe0:	02078793          	addi	a5,a5,32
    80001fe4:	02070713          	addi	a4,a4,32
    80001fe8:	fed792e3          	bne	a5,a3,80001fcc <fork+0x56>
  np->tf->a0 = 0;
    80001fec:	0609b783          	ld	a5,96(s3)
    80001ff0:	0607b823          	sd	zero,112(a5)
    80001ff4:	0d800493          	li	s1,216
  for(i = 0; i < NOFILE; i++)
    80001ff8:	15800a13          	li	s4,344
    80001ffc:	a03d                	j	8000202a <fork+0xb4>
    freeproc(np);
    80001ffe:	854e                	mv	a0,s3
    80002000:	00000097          	auipc	ra,0x0
    80002004:	e24080e7          	jalr	-476(ra) # 80001e24 <freeproc>
    release(&np->lock);
    80002008:	854e                	mv	a0,s3
    8000200a:	fffff097          	auipc	ra,0xfffff
    8000200e:	cac080e7          	jalr	-852(ra) # 80000cb6 <release>
    return -1;
    80002012:	54fd                	li	s1,-1
    80002014:	a899                	j	8000206a <fork+0xf4>
      np->ofile[i] = filedup(p->ofile[i]);
    80002016:	00003097          	auipc	ra,0x3
    8000201a:	8c6080e7          	jalr	-1850(ra) # 800048dc <filedup>
    8000201e:	009987b3          	add	a5,s3,s1
    80002022:	e388                	sd	a0,0(a5)
  for(i = 0; i < NOFILE; i++)
    80002024:	04a1                	addi	s1,s1,8
    80002026:	01448763          	beq	s1,s4,80002034 <fork+0xbe>
    if(p->ofile[i])
    8000202a:	009907b3          	add	a5,s2,s1
    8000202e:	6388                	ld	a0,0(a5)
    80002030:	f17d                	bnez	a0,80002016 <fork+0xa0>
    80002032:	bfcd                	j	80002024 <fork+0xae>
  np->cwd = idup(p->cwd);
    80002034:	15893503          	ld	a0,344(s2)
    80002038:	00002097          	auipc	ra,0x2
    8000203c:	8fe080e7          	jalr	-1794(ra) # 80003936 <idup>
    80002040:	14a9bc23          	sd	a0,344(s3)
  safestrcpy(np->name, p->name, sizeof(p->name));
    80002044:	4641                	li	a2,16
    80002046:	16090593          	addi	a1,s2,352
    8000204a:	16098513          	addi	a0,s3,352
    8000204e:	fffff097          	auipc	ra,0xfffff
    80002052:	006080e7          	jalr	6(ra) # 80001054 <safestrcpy>
  pid = np->pid;
    80002056:	0409a483          	lw	s1,64(s3)
  np->state = RUNNABLE;
    8000205a:	4789                	li	a5,2
    8000205c:	02f9a023          	sw	a5,32(s3)
  release(&np->lock);
    80002060:	854e                	mv	a0,s3
    80002062:	fffff097          	auipc	ra,0xfffff
    80002066:	c54080e7          	jalr	-940(ra) # 80000cb6 <release>
}
    8000206a:	8526                	mv	a0,s1
    8000206c:	70a2                	ld	ra,40(sp)
    8000206e:	7402                	ld	s0,32(sp)
    80002070:	64e2                	ld	s1,24(sp)
    80002072:	6942                	ld	s2,16(sp)
    80002074:	69a2                	ld	s3,8(sp)
    80002076:	6a02                	ld	s4,0(sp)
    80002078:	6145                	addi	sp,sp,48
    8000207a:	8082                	ret
    return -1;
    8000207c:	54fd                	li	s1,-1
    8000207e:	b7f5                	j	8000206a <fork+0xf4>

0000000080002080 <reparent>:
{
    80002080:	7179                	addi	sp,sp,-48
    80002082:	f406                	sd	ra,40(sp)
    80002084:	f022                	sd	s0,32(sp)
    80002086:	ec26                	sd	s1,24(sp)
    80002088:	e84a                	sd	s2,16(sp)
    8000208a:	e44e                	sd	s3,8(sp)
    8000208c:	e052                	sd	s4,0(sp)
    8000208e:	1800                	addi	s0,sp,48
    80002090:	89aa                	mv	s3,a0
  for(pp = proc; pp < &proc[NPROC]; pp++){
    80002092:	00013497          	auipc	s1,0x13
    80002096:	ce648493          	addi	s1,s1,-794 # 80014d78 <proc>
      pp->parent = initproc;
    8000209a:	0002ea17          	auipc	s4,0x2e
    8000209e:	f9ea0a13          	addi	s4,s4,-98 # 80030038 <initproc>
  for(pp = proc; pp < &proc[NPROC]; pp++){
    800020a2:	00019917          	auipc	s2,0x19
    800020a6:	8d690913          	addi	s2,s2,-1834 # 8001a978 <tickslock>
    800020aa:	a029                	j	800020b4 <reparent+0x34>
    800020ac:	17048493          	addi	s1,s1,368
    800020b0:	03248363          	beq	s1,s2,800020d6 <reparent+0x56>
    if(pp->parent == p){
    800020b4:	749c                	ld	a5,40(s1)
    800020b6:	ff379be3          	bne	a5,s3,800020ac <reparent+0x2c>
      acquire(&pp->lock);
    800020ba:	8526                	mv	a0,s1
    800020bc:	fffff097          	auipc	ra,0xfffff
    800020c0:	b8a080e7          	jalr	-1142(ra) # 80000c46 <acquire>
      pp->parent = initproc;
    800020c4:	000a3783          	ld	a5,0(s4)
    800020c8:	f49c                	sd	a5,40(s1)
      release(&pp->lock);
    800020ca:	8526                	mv	a0,s1
    800020cc:	fffff097          	auipc	ra,0xfffff
    800020d0:	bea080e7          	jalr	-1046(ra) # 80000cb6 <release>
    800020d4:	bfe1                	j	800020ac <reparent+0x2c>
}
    800020d6:	70a2                	ld	ra,40(sp)
    800020d8:	7402                	ld	s0,32(sp)
    800020da:	64e2                	ld	s1,24(sp)
    800020dc:	6942                	ld	s2,16(sp)
    800020de:	69a2                	ld	s3,8(sp)
    800020e0:	6a02                	ld	s4,0(sp)
    800020e2:	6145                	addi	sp,sp,48
    800020e4:	8082                	ret

00000000800020e6 <scheduler>:
{
    800020e6:	715d                	addi	sp,sp,-80
    800020e8:	e486                	sd	ra,72(sp)
    800020ea:	e0a2                	sd	s0,64(sp)
    800020ec:	fc26                	sd	s1,56(sp)
    800020ee:	f84a                	sd	s2,48(sp)
    800020f0:	f44e                	sd	s3,40(sp)
    800020f2:	f052                	sd	s4,32(sp)
    800020f4:	ec56                	sd	s5,24(sp)
    800020f6:	e85a                	sd	s6,16(sp)
    800020f8:	e45e                	sd	s7,8(sp)
    800020fa:	e062                	sd	s8,0(sp)
    800020fc:	0880                	addi	s0,sp,80
    800020fe:	8792                	mv	a5,tp
  int id = r_tp();
    80002100:	2781                	sext.w	a5,a5
  c->proc = 0;
    80002102:	00779b13          	slli	s6,a5,0x7
    80002106:	00013717          	auipc	a4,0x13
    8000210a:	85270713          	addi	a4,a4,-1966 # 80014958 <pid_lock>
    8000210e:	975a                	add	a4,a4,s6
    80002110:	02073023          	sd	zero,32(a4)
        swtch(&c->scheduler, &p->context);
    80002114:	00013717          	auipc	a4,0x13
    80002118:	86c70713          	addi	a4,a4,-1940 # 80014980 <cpus+0x8>
    8000211c:	9b3a                	add	s6,s6,a4
        p->state = RUNNING;
    8000211e:	4c0d                	li	s8,3
        c->proc = p;
    80002120:	079e                	slli	a5,a5,0x7
    80002122:	00013a17          	auipc	s4,0x13
    80002126:	836a0a13          	addi	s4,s4,-1994 # 80014958 <pid_lock>
    8000212a:	9a3e                	add	s4,s4,a5
    for(p = proc; p < &proc[NPROC]; p++) {
    8000212c:	00019997          	auipc	s3,0x19
    80002130:	84c98993          	addi	s3,s3,-1972 # 8001a978 <tickslock>
        found = 1;
    80002134:	4b85                	li	s7,1
    80002136:	a08d                	j	80002198 <scheduler+0xb2>
        p->state = RUNNING;
    80002138:	0384a023          	sw	s8,32(s1)
        c->proc = p;
    8000213c:	029a3023          	sd	s1,32(s4)
        swtch(&c->scheduler, &p->context);
    80002140:	06848593          	addi	a1,s1,104
    80002144:	855a                	mv	a0,s6
    80002146:	00000097          	auipc	ra,0x0
    8000214a:	65a080e7          	jalr	1626(ra) # 800027a0 <swtch>
        c->proc = 0;
    8000214e:	020a3023          	sd	zero,32(s4)
        found = 1;
    80002152:	8ade                	mv	s5,s7
      release(&p->lock);
    80002154:	8526                	mv	a0,s1
    80002156:	fffff097          	auipc	ra,0xfffff
    8000215a:	b60080e7          	jalr	-1184(ra) # 80000cb6 <release>
    for(p = proc; p < &proc[NPROC]; p++) {
    8000215e:	17048493          	addi	s1,s1,368
    80002162:	01348b63          	beq	s1,s3,80002178 <scheduler+0x92>
      acquire(&p->lock);
    80002166:	8526                	mv	a0,s1
    80002168:	fffff097          	auipc	ra,0xfffff
    8000216c:	ade080e7          	jalr	-1314(ra) # 80000c46 <acquire>
      if(p->state == RUNNABLE) {
    80002170:	509c                	lw	a5,32(s1)
    80002172:	ff2791e3          	bne	a5,s2,80002154 <scheduler+0x6e>
    80002176:	b7c9                	j	80002138 <scheduler+0x52>
    if(found == 0){
    80002178:	020a9063          	bnez	s5,80002198 <scheduler+0xb2>
  asm volatile("csrr %0, sie" : "=r" (x) );
    8000217c:	104027f3          	csrr	a5,sie
  w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
    80002180:	2227e793          	ori	a5,a5,546
  asm volatile("csrw sie, %0" : : "r" (x));
    80002184:	10479073          	csrw	sie,a5
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002188:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    8000218c:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002190:	10079073          	csrw	sstatus,a5
      asm volatile("wfi");
    80002194:	10500073          	wfi
  asm volatile("csrr %0, sie" : "=r" (x) );
    80002198:	104027f3          	csrr	a5,sie
  w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
    8000219c:	2227e793          	ori	a5,a5,546
  asm volatile("csrw sie, %0" : : "r" (x));
    800021a0:	10479073          	csrw	sie,a5
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800021a4:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    800021a8:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    800021ac:	10079073          	csrw	sstatus,a5
    int found = 0;
    800021b0:	4a81                	li	s5,0
    for(p = proc; p < &proc[NPROC]; p++) {
    800021b2:	00013497          	auipc	s1,0x13
    800021b6:	bc648493          	addi	s1,s1,-1082 # 80014d78 <proc>
      if(p->state == RUNNABLE) {
    800021ba:	4909                	li	s2,2
    800021bc:	b76d                	j	80002166 <scheduler+0x80>

00000000800021be <sched>:
{
    800021be:	7179                	addi	sp,sp,-48
    800021c0:	f406                	sd	ra,40(sp)
    800021c2:	f022                	sd	s0,32(sp)
    800021c4:	ec26                	sd	s1,24(sp)
    800021c6:	e84a                	sd	s2,16(sp)
    800021c8:	e44e                	sd	s3,8(sp)
    800021ca:	1800                	addi	s0,sp,48
  struct proc *p = myproc();
    800021cc:	00000097          	auipc	ra,0x0
    800021d0:	a3a080e7          	jalr	-1478(ra) # 80001c06 <myproc>
    800021d4:	892a                	mv	s2,a0
  if(!holding(&p->lock))
    800021d6:	fffff097          	auipc	ra,0xfffff
    800021da:	a30080e7          	jalr	-1488(ra) # 80000c06 <holding>
    800021de:	cd25                	beqz	a0,80002256 <sched+0x98>
  asm volatile("mv %0, tp" : "=r" (x) );
    800021e0:	8792                	mv	a5,tp
  if(mycpu()->noff != 1)
    800021e2:	2781                	sext.w	a5,a5
    800021e4:	079e                	slli	a5,a5,0x7
    800021e6:	00012717          	auipc	a4,0x12
    800021ea:	77270713          	addi	a4,a4,1906 # 80014958 <pid_lock>
    800021ee:	97ba                	add	a5,a5,a4
    800021f0:	0987a703          	lw	a4,152(a5)
    800021f4:	4785                	li	a5,1
    800021f6:	06f71863          	bne	a4,a5,80002266 <sched+0xa8>
  if(p->state == RUNNING)
    800021fa:	02092703          	lw	a4,32(s2)
    800021fe:	478d                	li	a5,3
    80002200:	06f70b63          	beq	a4,a5,80002276 <sched+0xb8>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002204:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80002208:	8b89                	andi	a5,a5,2
  if(intr_get())
    8000220a:	efb5                	bnez	a5,80002286 <sched+0xc8>
  asm volatile("mv %0, tp" : "=r" (x) );
    8000220c:	8792                	mv	a5,tp
  intena = mycpu()->intena;
    8000220e:	00012497          	auipc	s1,0x12
    80002212:	74a48493          	addi	s1,s1,1866 # 80014958 <pid_lock>
    80002216:	2781                	sext.w	a5,a5
    80002218:	079e                	slli	a5,a5,0x7
    8000221a:	97a6                	add	a5,a5,s1
    8000221c:	09c7a983          	lw	s3,156(a5)
    80002220:	8792                	mv	a5,tp
  swtch(&p->context, &mycpu()->scheduler);
    80002222:	2781                	sext.w	a5,a5
    80002224:	079e                	slli	a5,a5,0x7
    80002226:	00012597          	auipc	a1,0x12
    8000222a:	75a58593          	addi	a1,a1,1882 # 80014980 <cpus+0x8>
    8000222e:	95be                	add	a1,a1,a5
    80002230:	06890513          	addi	a0,s2,104
    80002234:	00000097          	auipc	ra,0x0
    80002238:	56c080e7          	jalr	1388(ra) # 800027a0 <swtch>
    8000223c:	8792                	mv	a5,tp
  mycpu()->intena = intena;
    8000223e:	2781                	sext.w	a5,a5
    80002240:	079e                	slli	a5,a5,0x7
    80002242:	97a6                	add	a5,a5,s1
    80002244:	0937ae23          	sw	s3,156(a5)
}
    80002248:	70a2                	ld	ra,40(sp)
    8000224a:	7402                	ld	s0,32(sp)
    8000224c:	64e2                	ld	s1,24(sp)
    8000224e:	6942                	ld	s2,16(sp)
    80002250:	69a2                	ld	s3,8(sp)
    80002252:	6145                	addi	sp,sp,48
    80002254:	8082                	ret
    panic("sched p->lock");
    80002256:	00006517          	auipc	a0,0x6
    8000225a:	20250513          	addi	a0,a0,514 # 80008458 <userret+0x3c8>
    8000225e:	ffffe097          	auipc	ra,0xffffe
    80002262:	320080e7          	jalr	800(ra) # 8000057e <panic>
    panic("sched locks");
    80002266:	00006517          	auipc	a0,0x6
    8000226a:	20250513          	addi	a0,a0,514 # 80008468 <userret+0x3d8>
    8000226e:	ffffe097          	auipc	ra,0xffffe
    80002272:	310080e7          	jalr	784(ra) # 8000057e <panic>
    panic("sched running");
    80002276:	00006517          	auipc	a0,0x6
    8000227a:	20250513          	addi	a0,a0,514 # 80008478 <userret+0x3e8>
    8000227e:	ffffe097          	auipc	ra,0xffffe
    80002282:	300080e7          	jalr	768(ra) # 8000057e <panic>
    panic("sched interruptible");
    80002286:	00006517          	auipc	a0,0x6
    8000228a:	20250513          	addi	a0,a0,514 # 80008488 <userret+0x3f8>
    8000228e:	ffffe097          	auipc	ra,0xffffe
    80002292:	2f0080e7          	jalr	752(ra) # 8000057e <panic>

0000000080002296 <exit>:
{
    80002296:	7179                	addi	sp,sp,-48
    80002298:	f406                	sd	ra,40(sp)
    8000229a:	f022                	sd	s0,32(sp)
    8000229c:	ec26                	sd	s1,24(sp)
    8000229e:	e84a                	sd	s2,16(sp)
    800022a0:	e44e                	sd	s3,8(sp)
    800022a2:	e052                	sd	s4,0(sp)
    800022a4:	1800                	addi	s0,sp,48
    800022a6:	8a2a                	mv	s4,a0
  struct proc *p = myproc();
    800022a8:	00000097          	auipc	ra,0x0
    800022ac:	95e080e7          	jalr	-1698(ra) # 80001c06 <myproc>
    800022b0:	89aa                	mv	s3,a0
  if(p == initproc)
    800022b2:	0002e797          	auipc	a5,0x2e
    800022b6:	d8678793          	addi	a5,a5,-634 # 80030038 <initproc>
    800022ba:	639c                	ld	a5,0(a5)
    800022bc:	0d850493          	addi	s1,a0,216
    800022c0:	15850913          	addi	s2,a0,344
    800022c4:	02a79363          	bne	a5,a0,800022ea <exit+0x54>
    panic("init exiting");
    800022c8:	00006517          	auipc	a0,0x6
    800022cc:	1d850513          	addi	a0,a0,472 # 800084a0 <userret+0x410>
    800022d0:	ffffe097          	auipc	ra,0xffffe
    800022d4:	2ae080e7          	jalr	686(ra) # 8000057e <panic>
      fileclose(f);
    800022d8:	00002097          	auipc	ra,0x2
    800022dc:	656080e7          	jalr	1622(ra) # 8000492e <fileclose>
      p->ofile[fd] = 0;
    800022e0:	0004b023          	sd	zero,0(s1)
  for(int fd = 0; fd < NOFILE; fd++){
    800022e4:	04a1                	addi	s1,s1,8
    800022e6:	01248563          	beq	s1,s2,800022f0 <exit+0x5a>
    if(p->ofile[fd]){
    800022ea:	6088                	ld	a0,0(s1)
    800022ec:	f575                	bnez	a0,800022d8 <exit+0x42>
    800022ee:	bfdd                	j	800022e4 <exit+0x4e>
  begin_op(ROOTDEV);
    800022f0:	4501                	li	a0,0
    800022f2:	00002097          	auipc	ra,0x2
    800022f6:	070080e7          	jalr	112(ra) # 80004362 <begin_op>
  iput(p->cwd);
    800022fa:	1589b503          	ld	a0,344(s3)
    800022fe:	00001097          	auipc	ra,0x1
    80002302:	786080e7          	jalr	1926(ra) # 80003a84 <iput>
  end_op(ROOTDEV);
    80002306:	4501                	li	a0,0
    80002308:	00002097          	auipc	ra,0x2
    8000230c:	104080e7          	jalr	260(ra) # 8000440c <end_op>
  p->cwd = 0;
    80002310:	1409bc23          	sd	zero,344(s3)
  acquire(&initproc->lock);
    80002314:	0002e497          	auipc	s1,0x2e
    80002318:	d2448493          	addi	s1,s1,-732 # 80030038 <initproc>
    8000231c:	6088                	ld	a0,0(s1)
    8000231e:	fffff097          	auipc	ra,0xfffff
    80002322:	928080e7          	jalr	-1752(ra) # 80000c46 <acquire>
  wakeup1(initproc);
    80002326:	6088                	ld	a0,0(s1)
    80002328:	fffff097          	auipc	ra,0xfffff
    8000232c:	79e080e7          	jalr	1950(ra) # 80001ac6 <wakeup1>
  release(&initproc->lock);
    80002330:	6088                	ld	a0,0(s1)
    80002332:	fffff097          	auipc	ra,0xfffff
    80002336:	984080e7          	jalr	-1660(ra) # 80000cb6 <release>
  acquire(&p->lock);
    8000233a:	854e                	mv	a0,s3
    8000233c:	fffff097          	auipc	ra,0xfffff
    80002340:	90a080e7          	jalr	-1782(ra) # 80000c46 <acquire>
  struct proc *original_parent = p->parent;
    80002344:	0289b483          	ld	s1,40(s3)
  release(&p->lock);
    80002348:	854e                	mv	a0,s3
    8000234a:	fffff097          	auipc	ra,0xfffff
    8000234e:	96c080e7          	jalr	-1684(ra) # 80000cb6 <release>
  acquire(&original_parent->lock);
    80002352:	8526                	mv	a0,s1
    80002354:	fffff097          	auipc	ra,0xfffff
    80002358:	8f2080e7          	jalr	-1806(ra) # 80000c46 <acquire>
  acquire(&p->lock);
    8000235c:	854e                	mv	a0,s3
    8000235e:	fffff097          	auipc	ra,0xfffff
    80002362:	8e8080e7          	jalr	-1816(ra) # 80000c46 <acquire>
  reparent(p);
    80002366:	854e                	mv	a0,s3
    80002368:	00000097          	auipc	ra,0x0
    8000236c:	d18080e7          	jalr	-744(ra) # 80002080 <reparent>
  wakeup1(original_parent);
    80002370:	8526                	mv	a0,s1
    80002372:	fffff097          	auipc	ra,0xfffff
    80002376:	754080e7          	jalr	1876(ra) # 80001ac6 <wakeup1>
  p->xstate = status;
    8000237a:	0349ae23          	sw	s4,60(s3)
  p->state = ZOMBIE;
    8000237e:	4791                	li	a5,4
    80002380:	02f9a023          	sw	a5,32(s3)
  release(&original_parent->lock);
    80002384:	8526                	mv	a0,s1
    80002386:	fffff097          	auipc	ra,0xfffff
    8000238a:	930080e7          	jalr	-1744(ra) # 80000cb6 <release>
  sched();
    8000238e:	00000097          	auipc	ra,0x0
    80002392:	e30080e7          	jalr	-464(ra) # 800021be <sched>
  panic("zombie exit");
    80002396:	00006517          	auipc	a0,0x6
    8000239a:	11a50513          	addi	a0,a0,282 # 800084b0 <userret+0x420>
    8000239e:	ffffe097          	auipc	ra,0xffffe
    800023a2:	1e0080e7          	jalr	480(ra) # 8000057e <panic>

00000000800023a6 <yield>:
{
    800023a6:	1101                	addi	sp,sp,-32
    800023a8:	ec06                	sd	ra,24(sp)
    800023aa:	e822                	sd	s0,16(sp)
    800023ac:	e426                	sd	s1,8(sp)
    800023ae:	1000                	addi	s0,sp,32
  struct proc *p = myproc();
    800023b0:	00000097          	auipc	ra,0x0
    800023b4:	856080e7          	jalr	-1962(ra) # 80001c06 <myproc>
    800023b8:	84aa                	mv	s1,a0
  acquire(&p->lock);
    800023ba:	fffff097          	auipc	ra,0xfffff
    800023be:	88c080e7          	jalr	-1908(ra) # 80000c46 <acquire>
  p->state = RUNNABLE;
    800023c2:	4789                	li	a5,2
    800023c4:	d09c                	sw	a5,32(s1)
  sched();
    800023c6:	00000097          	auipc	ra,0x0
    800023ca:	df8080e7          	jalr	-520(ra) # 800021be <sched>
  release(&p->lock);
    800023ce:	8526                	mv	a0,s1
    800023d0:	fffff097          	auipc	ra,0xfffff
    800023d4:	8e6080e7          	jalr	-1818(ra) # 80000cb6 <release>
}
    800023d8:	60e2                	ld	ra,24(sp)
    800023da:	6442                	ld	s0,16(sp)
    800023dc:	64a2                	ld	s1,8(sp)
    800023de:	6105                	addi	sp,sp,32
    800023e0:	8082                	ret

00000000800023e2 <sleep>:
{
    800023e2:	7179                	addi	sp,sp,-48
    800023e4:	f406                	sd	ra,40(sp)
    800023e6:	f022                	sd	s0,32(sp)
    800023e8:	ec26                	sd	s1,24(sp)
    800023ea:	e84a                	sd	s2,16(sp)
    800023ec:	e44e                	sd	s3,8(sp)
    800023ee:	1800                	addi	s0,sp,48
    800023f0:	89aa                	mv	s3,a0
    800023f2:	892e                	mv	s2,a1
  struct proc *p = myproc();
    800023f4:	00000097          	auipc	ra,0x0
    800023f8:	812080e7          	jalr	-2030(ra) # 80001c06 <myproc>
    800023fc:	84aa                	mv	s1,a0
  if(lk != &p->lock){  //DOC: sleeplock0
    800023fe:	05250663          	beq	a0,s2,8000244a <sleep+0x68>
    acquire(&p->lock);  //DOC: sleeplock1
    80002402:	fffff097          	auipc	ra,0xfffff
    80002406:	844080e7          	jalr	-1980(ra) # 80000c46 <acquire>
    release(lk);
    8000240a:	854a                	mv	a0,s2
    8000240c:	fffff097          	auipc	ra,0xfffff
    80002410:	8aa080e7          	jalr	-1878(ra) # 80000cb6 <release>
  p->chan = chan;
    80002414:	0334b823          	sd	s3,48(s1)
  p->state = SLEEPING;
    80002418:	4785                	li	a5,1
    8000241a:	d09c                	sw	a5,32(s1)
  sched();
    8000241c:	00000097          	auipc	ra,0x0
    80002420:	da2080e7          	jalr	-606(ra) # 800021be <sched>
  p->chan = 0;
    80002424:	0204b823          	sd	zero,48(s1)
    release(&p->lock);
    80002428:	8526                	mv	a0,s1
    8000242a:	fffff097          	auipc	ra,0xfffff
    8000242e:	88c080e7          	jalr	-1908(ra) # 80000cb6 <release>
    acquire(lk);
    80002432:	854a                	mv	a0,s2
    80002434:	fffff097          	auipc	ra,0xfffff
    80002438:	812080e7          	jalr	-2030(ra) # 80000c46 <acquire>
}
    8000243c:	70a2                	ld	ra,40(sp)
    8000243e:	7402                	ld	s0,32(sp)
    80002440:	64e2                	ld	s1,24(sp)
    80002442:	6942                	ld	s2,16(sp)
    80002444:	69a2                	ld	s3,8(sp)
    80002446:	6145                	addi	sp,sp,48
    80002448:	8082                	ret
  p->chan = chan;
    8000244a:	03353823          	sd	s3,48(a0)
  p->state = SLEEPING;
    8000244e:	4785                	li	a5,1
    80002450:	d11c                	sw	a5,32(a0)
  sched();
    80002452:	00000097          	auipc	ra,0x0
    80002456:	d6c080e7          	jalr	-660(ra) # 800021be <sched>
  p->chan = 0;
    8000245a:	0204b823          	sd	zero,48(s1)
  if(lk != &p->lock){
    8000245e:	bff9                	j	8000243c <sleep+0x5a>

0000000080002460 <wait>:
{
    80002460:	715d                	addi	sp,sp,-80
    80002462:	e486                	sd	ra,72(sp)
    80002464:	e0a2                	sd	s0,64(sp)
    80002466:	fc26                	sd	s1,56(sp)
    80002468:	f84a                	sd	s2,48(sp)
    8000246a:	f44e                	sd	s3,40(sp)
    8000246c:	f052                	sd	s4,32(sp)
    8000246e:	ec56                	sd	s5,24(sp)
    80002470:	e85a                	sd	s6,16(sp)
    80002472:	e45e                	sd	s7,8(sp)
    80002474:	e062                	sd	s8,0(sp)
    80002476:	0880                	addi	s0,sp,80
    80002478:	8baa                	mv	s7,a0
  struct proc *p = myproc();
    8000247a:	fffff097          	auipc	ra,0xfffff
    8000247e:	78c080e7          	jalr	1932(ra) # 80001c06 <myproc>
    80002482:	892a                	mv	s2,a0
  acquire(&p->lock);
    80002484:	8c2a                	mv	s8,a0
    80002486:	ffffe097          	auipc	ra,0xffffe
    8000248a:	7c0080e7          	jalr	1984(ra) # 80000c46 <acquire>
    havekids = 0;
    8000248e:	4b01                	li	s6,0
        if(np->state == ZOMBIE){
    80002490:	4a11                	li	s4,4
    for(np = proc; np < &proc[NPROC]; np++){
    80002492:	00018997          	auipc	s3,0x18
    80002496:	4e698993          	addi	s3,s3,1254 # 8001a978 <tickslock>
        havekids = 1;
    8000249a:	4a85                	li	s5,1
    havekids = 0;
    8000249c:	875a                	mv	a4,s6
    for(np = proc; np < &proc[NPROC]; np++){
    8000249e:	00013497          	auipc	s1,0x13
    800024a2:	8da48493          	addi	s1,s1,-1830 # 80014d78 <proc>
    800024a6:	a08d                	j	80002508 <wait+0xa8>
          pid = np->pid;
    800024a8:	0404a983          	lw	s3,64(s1)
          if(addr != 0 && copyout(p->pagetable, addr, (char *)&np->xstate,
    800024ac:	000b8e63          	beqz	s7,800024c8 <wait+0x68>
    800024b0:	4691                	li	a3,4
    800024b2:	03c48613          	addi	a2,s1,60
    800024b6:	85de                	mv	a1,s7
    800024b8:	05893503          	ld	a0,88(s2)
    800024bc:	fffff097          	auipc	ra,0xfffff
    800024c0:	426080e7          	jalr	1062(ra) # 800018e2 <copyout>
    800024c4:	02054263          	bltz	a0,800024e8 <wait+0x88>
          freeproc(np);
    800024c8:	8526                	mv	a0,s1
    800024ca:	00000097          	auipc	ra,0x0
    800024ce:	95a080e7          	jalr	-1702(ra) # 80001e24 <freeproc>
          release(&np->lock);
    800024d2:	8526                	mv	a0,s1
    800024d4:	ffffe097          	auipc	ra,0xffffe
    800024d8:	7e2080e7          	jalr	2018(ra) # 80000cb6 <release>
          release(&p->lock);
    800024dc:	854a                	mv	a0,s2
    800024de:	ffffe097          	auipc	ra,0xffffe
    800024e2:	7d8080e7          	jalr	2008(ra) # 80000cb6 <release>
          return pid;
    800024e6:	a8a9                	j	80002540 <wait+0xe0>
            release(&np->lock);
    800024e8:	8526                	mv	a0,s1
    800024ea:	ffffe097          	auipc	ra,0xffffe
    800024ee:	7cc080e7          	jalr	1996(ra) # 80000cb6 <release>
            release(&p->lock);
    800024f2:	854a                	mv	a0,s2
    800024f4:	ffffe097          	auipc	ra,0xffffe
    800024f8:	7c2080e7          	jalr	1986(ra) # 80000cb6 <release>
            return -1;
    800024fc:	59fd                	li	s3,-1
    800024fe:	a089                	j	80002540 <wait+0xe0>
    for(np = proc; np < &proc[NPROC]; np++){
    80002500:	17048493          	addi	s1,s1,368
    80002504:	03348463          	beq	s1,s3,8000252c <wait+0xcc>
      if(np->parent == p){
    80002508:	749c                	ld	a5,40(s1)
    8000250a:	ff279be3          	bne	a5,s2,80002500 <wait+0xa0>
        acquire(&np->lock);
    8000250e:	8526                	mv	a0,s1
    80002510:	ffffe097          	auipc	ra,0xffffe
    80002514:	736080e7          	jalr	1846(ra) # 80000c46 <acquire>
        if(np->state == ZOMBIE){
    80002518:	509c                	lw	a5,32(s1)
    8000251a:	f94787e3          	beq	a5,s4,800024a8 <wait+0x48>
        release(&np->lock);
    8000251e:	8526                	mv	a0,s1
    80002520:	ffffe097          	auipc	ra,0xffffe
    80002524:	796080e7          	jalr	1942(ra) # 80000cb6 <release>
        havekids = 1;
    80002528:	8756                	mv	a4,s5
    8000252a:	bfd9                	j	80002500 <wait+0xa0>
    if(!havekids || p->killed){
    8000252c:	c701                	beqz	a4,80002534 <wait+0xd4>
    8000252e:	03892783          	lw	a5,56(s2)
    80002532:	c785                	beqz	a5,8000255a <wait+0xfa>
      release(&p->lock);
    80002534:	854a                	mv	a0,s2
    80002536:	ffffe097          	auipc	ra,0xffffe
    8000253a:	780080e7          	jalr	1920(ra) # 80000cb6 <release>
      return -1;
    8000253e:	59fd                	li	s3,-1
}
    80002540:	854e                	mv	a0,s3
    80002542:	60a6                	ld	ra,72(sp)
    80002544:	6406                	ld	s0,64(sp)
    80002546:	74e2                	ld	s1,56(sp)
    80002548:	7942                	ld	s2,48(sp)
    8000254a:	79a2                	ld	s3,40(sp)
    8000254c:	7a02                	ld	s4,32(sp)
    8000254e:	6ae2                	ld	s5,24(sp)
    80002550:	6b42                	ld	s6,16(sp)
    80002552:	6ba2                	ld	s7,8(sp)
    80002554:	6c02                	ld	s8,0(sp)
    80002556:	6161                	addi	sp,sp,80
    80002558:	8082                	ret
    sleep(p, &p->lock);  //DOC: wait-sleep
    8000255a:	85e2                	mv	a1,s8
    8000255c:	854a                	mv	a0,s2
    8000255e:	00000097          	auipc	ra,0x0
    80002562:	e84080e7          	jalr	-380(ra) # 800023e2 <sleep>
    havekids = 0;
    80002566:	bf1d                	j	8000249c <wait+0x3c>

0000000080002568 <wakeup>:
{
    80002568:	7139                	addi	sp,sp,-64
    8000256a:	fc06                	sd	ra,56(sp)
    8000256c:	f822                	sd	s0,48(sp)
    8000256e:	f426                	sd	s1,40(sp)
    80002570:	f04a                	sd	s2,32(sp)
    80002572:	ec4e                	sd	s3,24(sp)
    80002574:	e852                	sd	s4,16(sp)
    80002576:	e456                	sd	s5,8(sp)
    80002578:	0080                	addi	s0,sp,64
    8000257a:	8a2a                	mv	s4,a0
  for(p = proc; p < &proc[NPROC]; p++) {
    8000257c:	00012497          	auipc	s1,0x12
    80002580:	7fc48493          	addi	s1,s1,2044 # 80014d78 <proc>
    if(p->state == SLEEPING && p->chan == chan) {
    80002584:	4985                	li	s3,1
      p->state = RUNNABLE;
    80002586:	4a89                	li	s5,2
  for(p = proc; p < &proc[NPROC]; p++) {
    80002588:	00018917          	auipc	s2,0x18
    8000258c:	3f090913          	addi	s2,s2,1008 # 8001a978 <tickslock>
    80002590:	a821                	j	800025a8 <wakeup+0x40>
      p->state = RUNNABLE;
    80002592:	0354a023          	sw	s5,32(s1)
    release(&p->lock);
    80002596:	8526                	mv	a0,s1
    80002598:	ffffe097          	auipc	ra,0xffffe
    8000259c:	71e080e7          	jalr	1822(ra) # 80000cb6 <release>
  for(p = proc; p < &proc[NPROC]; p++) {
    800025a0:	17048493          	addi	s1,s1,368
    800025a4:	01248e63          	beq	s1,s2,800025c0 <wakeup+0x58>
    acquire(&p->lock);
    800025a8:	8526                	mv	a0,s1
    800025aa:	ffffe097          	auipc	ra,0xffffe
    800025ae:	69c080e7          	jalr	1692(ra) # 80000c46 <acquire>
    if(p->state == SLEEPING && p->chan == chan) {
    800025b2:	509c                	lw	a5,32(s1)
    800025b4:	ff3791e3          	bne	a5,s3,80002596 <wakeup+0x2e>
    800025b8:	789c                	ld	a5,48(s1)
    800025ba:	fd479ee3          	bne	a5,s4,80002596 <wakeup+0x2e>
    800025be:	bfd1                	j	80002592 <wakeup+0x2a>
}
    800025c0:	70e2                	ld	ra,56(sp)
    800025c2:	7442                	ld	s0,48(sp)
    800025c4:	74a2                	ld	s1,40(sp)
    800025c6:	7902                	ld	s2,32(sp)
    800025c8:	69e2                	ld	s3,24(sp)
    800025ca:	6a42                	ld	s4,16(sp)
    800025cc:	6aa2                	ld	s5,8(sp)
    800025ce:	6121                	addi	sp,sp,64
    800025d0:	8082                	ret

00000000800025d2 <kill>:
// Kill the process with the given pid.
// The victim won't exit until it tries to return
// to user space (see usertrap() in trap.c).
int
kill(int pid)
{
    800025d2:	7179                	addi	sp,sp,-48
    800025d4:	f406                	sd	ra,40(sp)
    800025d6:	f022                	sd	s0,32(sp)
    800025d8:	ec26                	sd	s1,24(sp)
    800025da:	e84a                	sd	s2,16(sp)
    800025dc:	e44e                	sd	s3,8(sp)
    800025de:	1800                	addi	s0,sp,48
    800025e0:	892a                	mv	s2,a0
  struct proc *p;

  for(p = proc; p < &proc[NPROC]; p++){
    800025e2:	00012497          	auipc	s1,0x12
    800025e6:	79648493          	addi	s1,s1,1942 # 80014d78 <proc>
    800025ea:	00018997          	auipc	s3,0x18
    800025ee:	38e98993          	addi	s3,s3,910 # 8001a978 <tickslock>
    acquire(&p->lock);
    800025f2:	8526                	mv	a0,s1
    800025f4:	ffffe097          	auipc	ra,0xffffe
    800025f8:	652080e7          	jalr	1618(ra) # 80000c46 <acquire>
    if(p->pid == pid){
    800025fc:	40bc                	lw	a5,64(s1)
    800025fe:	01278d63          	beq	a5,s2,80002618 <kill+0x46>
        p->state = RUNNABLE;
      }
      release(&p->lock);
      return 0;
    }
    release(&p->lock);
    80002602:	8526                	mv	a0,s1
    80002604:	ffffe097          	auipc	ra,0xffffe
    80002608:	6b2080e7          	jalr	1714(ra) # 80000cb6 <release>
  for(p = proc; p < &proc[NPROC]; p++){
    8000260c:	17048493          	addi	s1,s1,368
    80002610:	ff3491e3          	bne	s1,s3,800025f2 <kill+0x20>
  }
  return -1;
    80002614:	557d                	li	a0,-1
    80002616:	a829                	j	80002630 <kill+0x5e>
      p->killed = 1;
    80002618:	4785                	li	a5,1
    8000261a:	dc9c                	sw	a5,56(s1)
      if(p->state == SLEEPING){
    8000261c:	5098                	lw	a4,32(s1)
    8000261e:	4785                	li	a5,1
    80002620:	00f70f63          	beq	a4,a5,8000263e <kill+0x6c>
      release(&p->lock);
    80002624:	8526                	mv	a0,s1
    80002626:	ffffe097          	auipc	ra,0xffffe
    8000262a:	690080e7          	jalr	1680(ra) # 80000cb6 <release>
      return 0;
    8000262e:	4501                	li	a0,0
}
    80002630:	70a2                	ld	ra,40(sp)
    80002632:	7402                	ld	s0,32(sp)
    80002634:	64e2                	ld	s1,24(sp)
    80002636:	6942                	ld	s2,16(sp)
    80002638:	69a2                	ld	s3,8(sp)
    8000263a:	6145                	addi	sp,sp,48
    8000263c:	8082                	ret
        p->state = RUNNABLE;
    8000263e:	4789                	li	a5,2
    80002640:	d09c                	sw	a5,32(s1)
    80002642:	b7cd                	j	80002624 <kill+0x52>

0000000080002644 <either_copyout>:
// Copy to either a user address, or kernel address,
// depending on usr_dst.
// Returns 0 on success, -1 on error.
int
either_copyout(int user_dst, uint64 dst, void *src, uint64 len)
{
    80002644:	7179                	addi	sp,sp,-48
    80002646:	f406                	sd	ra,40(sp)
    80002648:	f022                	sd	s0,32(sp)
    8000264a:	ec26                	sd	s1,24(sp)
    8000264c:	e84a                	sd	s2,16(sp)
    8000264e:	e44e                	sd	s3,8(sp)
    80002650:	e052                	sd	s4,0(sp)
    80002652:	1800                	addi	s0,sp,48
    80002654:	84aa                	mv	s1,a0
    80002656:	892e                	mv	s2,a1
    80002658:	89b2                	mv	s3,a2
    8000265a:	8a36                	mv	s4,a3
  struct proc *p = myproc();
    8000265c:	fffff097          	auipc	ra,0xfffff
    80002660:	5aa080e7          	jalr	1450(ra) # 80001c06 <myproc>
  if(user_dst){
    80002664:	c08d                	beqz	s1,80002686 <either_copyout+0x42>
    return copyout(p->pagetable, dst, src, len);
    80002666:	86d2                	mv	a3,s4
    80002668:	864e                	mv	a2,s3
    8000266a:	85ca                	mv	a1,s2
    8000266c:	6d28                	ld	a0,88(a0)
    8000266e:	fffff097          	auipc	ra,0xfffff
    80002672:	274080e7          	jalr	628(ra) # 800018e2 <copyout>
  } else {
    memmove((char *)dst, src, len);
    return 0;
  }
}
    80002676:	70a2                	ld	ra,40(sp)
    80002678:	7402                	ld	s0,32(sp)
    8000267a:	64e2                	ld	s1,24(sp)
    8000267c:	6942                	ld	s2,16(sp)
    8000267e:	69a2                	ld	s3,8(sp)
    80002680:	6a02                	ld	s4,0(sp)
    80002682:	6145                	addi	sp,sp,48
    80002684:	8082                	ret
    memmove((char *)dst, src, len);
    80002686:	000a061b          	sext.w	a2,s4
    8000268a:	85ce                	mv	a1,s3
    8000268c:	854a                	mv	a0,s2
    8000268e:	fffff097          	auipc	ra,0xfffff
    80002692:	8ba080e7          	jalr	-1862(ra) # 80000f48 <memmove>
    return 0;
    80002696:	8526                	mv	a0,s1
    80002698:	bff9                	j	80002676 <either_copyout+0x32>

000000008000269a <either_copyin>:
// Copy from either a user address, or kernel address,
// depending on usr_src.
// Returns 0 on success, -1 on error.
int
either_copyin(void *dst, int user_src, uint64 src, uint64 len)
{
    8000269a:	7179                	addi	sp,sp,-48
    8000269c:	f406                	sd	ra,40(sp)
    8000269e:	f022                	sd	s0,32(sp)
    800026a0:	ec26                	sd	s1,24(sp)
    800026a2:	e84a                	sd	s2,16(sp)
    800026a4:	e44e                	sd	s3,8(sp)
    800026a6:	e052                	sd	s4,0(sp)
    800026a8:	1800                	addi	s0,sp,48
    800026aa:	892a                	mv	s2,a0
    800026ac:	84ae                	mv	s1,a1
    800026ae:	89b2                	mv	s3,a2
    800026b0:	8a36                	mv	s4,a3
  struct proc *p = myproc();
    800026b2:	fffff097          	auipc	ra,0xfffff
    800026b6:	554080e7          	jalr	1364(ra) # 80001c06 <myproc>
  if(user_src){
    800026ba:	c08d                	beqz	s1,800026dc <either_copyin+0x42>
    return copyin(p->pagetable, dst, src, len);
    800026bc:	86d2                	mv	a3,s4
    800026be:	864e                	mv	a2,s3
    800026c0:	85ca                	mv	a1,s2
    800026c2:	6d28                	ld	a0,88(a0)
    800026c4:	fffff097          	auipc	ra,0xfffff
    800026c8:	2aa080e7          	jalr	682(ra) # 8000196e <copyin>
  } else {
    memmove(dst, (char*)src, len);
    return 0;
  }
}
    800026cc:	70a2                	ld	ra,40(sp)
    800026ce:	7402                	ld	s0,32(sp)
    800026d0:	64e2                	ld	s1,24(sp)
    800026d2:	6942                	ld	s2,16(sp)
    800026d4:	69a2                	ld	s3,8(sp)
    800026d6:	6a02                	ld	s4,0(sp)
    800026d8:	6145                	addi	sp,sp,48
    800026da:	8082                	ret
    memmove(dst, (char*)src, len);
    800026dc:	000a061b          	sext.w	a2,s4
    800026e0:	85ce                	mv	a1,s3
    800026e2:	854a                	mv	a0,s2
    800026e4:	fffff097          	auipc	ra,0xfffff
    800026e8:	864080e7          	jalr	-1948(ra) # 80000f48 <memmove>
    return 0;
    800026ec:	8526                	mv	a0,s1
    800026ee:	bff9                	j	800026cc <either_copyin+0x32>

00000000800026f0 <procdump>:
// Print a process listing to console.  For debugging.
// Runs when user types ^P on console.
// No lock to avoid wedging a stuck machine further.
void
procdump(void)
{
    800026f0:	715d                	addi	sp,sp,-80
    800026f2:	e486                	sd	ra,72(sp)
    800026f4:	e0a2                	sd	s0,64(sp)
    800026f6:	fc26                	sd	s1,56(sp)
    800026f8:	f84a                	sd	s2,48(sp)
    800026fa:	f44e                	sd	s3,40(sp)
    800026fc:	f052                	sd	s4,32(sp)
    800026fe:	ec56                	sd	s5,24(sp)
    80002700:	e85a                	sd	s6,16(sp)
    80002702:	e45e                	sd	s7,8(sp)
    80002704:	0880                	addi	s0,sp,80
  [ZOMBIE]    "zombie"
  };
  struct proc *p;
  char *state;

  printf("\n");
    80002706:	00006517          	auipc	a0,0x6
    8000270a:	b8a50513          	addi	a0,a0,-1142 # 80008290 <userret+0x200>
    8000270e:	ffffe097          	auipc	ra,0xffffe
    80002712:	eca080e7          	jalr	-310(ra) # 800005d8 <printf>
  for(p = proc; p < &proc[NPROC]; p++){
    80002716:	00012497          	auipc	s1,0x12
    8000271a:	7c248493          	addi	s1,s1,1986 # 80014ed8 <proc+0x160>
    8000271e:	00018917          	auipc	s2,0x18
    80002722:	3ba90913          	addi	s2,s2,954 # 8001aad8 <bcache+0x140>
    if(p->state == UNUSED)
      continue;
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    80002726:	4b11                	li	s6,4
      state = states[p->state];
    else
      state = "???";
    80002728:	00006997          	auipc	s3,0x6
    8000272c:	d9898993          	addi	s3,s3,-616 # 800084c0 <userret+0x430>
    printf("%d %s %s", p->pid, state, p->name);
    80002730:	00006a97          	auipc	s5,0x6
    80002734:	d98a8a93          	addi	s5,s5,-616 # 800084c8 <userret+0x438>
    printf("\n");
    80002738:	00006a17          	auipc	s4,0x6
    8000273c:	b58a0a13          	addi	s4,s4,-1192 # 80008290 <userret+0x200>
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    80002740:	00006b97          	auipc	s7,0x6
    80002744:	398b8b93          	addi	s7,s7,920 # 80008ad8 <states.1805>
    80002748:	a015                	j	8000276c <procdump+0x7c>
    printf("%d %s %s", p->pid, state, p->name);
    8000274a:	86ba                	mv	a3,a4
    8000274c:	ee072583          	lw	a1,-288(a4)
    80002750:	8556                	mv	a0,s5
    80002752:	ffffe097          	auipc	ra,0xffffe
    80002756:	e86080e7          	jalr	-378(ra) # 800005d8 <printf>
    printf("\n");
    8000275a:	8552                	mv	a0,s4
    8000275c:	ffffe097          	auipc	ra,0xffffe
    80002760:	e7c080e7          	jalr	-388(ra) # 800005d8 <printf>
  for(p = proc; p < &proc[NPROC]; p++){
    80002764:	17048493          	addi	s1,s1,368
    80002768:	03248163          	beq	s1,s2,8000278a <procdump+0x9a>
    if(p->state == UNUSED)
    8000276c:	8726                	mv	a4,s1
    8000276e:	ec04a783          	lw	a5,-320(s1)
    80002772:	dbed                	beqz	a5,80002764 <procdump+0x74>
      state = "???";
    80002774:	864e                	mv	a2,s3
    if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
    80002776:	fcfb6ae3          	bltu	s6,a5,8000274a <procdump+0x5a>
    8000277a:	1782                	slli	a5,a5,0x20
    8000277c:	9381                	srli	a5,a5,0x20
    8000277e:	078e                	slli	a5,a5,0x3
    80002780:	97de                	add	a5,a5,s7
    80002782:	6390                	ld	a2,0(a5)
    80002784:	f279                	bnez	a2,8000274a <procdump+0x5a>
      state = "???";
    80002786:	864e                	mv	a2,s3
    80002788:	b7c9                	j	8000274a <procdump+0x5a>
  }
}
    8000278a:	60a6                	ld	ra,72(sp)
    8000278c:	6406                	ld	s0,64(sp)
    8000278e:	74e2                	ld	s1,56(sp)
    80002790:	7942                	ld	s2,48(sp)
    80002792:	79a2                	ld	s3,40(sp)
    80002794:	7a02                	ld	s4,32(sp)
    80002796:	6ae2                	ld	s5,24(sp)
    80002798:	6b42                	ld	s6,16(sp)
    8000279a:	6ba2                	ld	s7,8(sp)
    8000279c:	6161                	addi	sp,sp,80
    8000279e:	8082                	ret

00000000800027a0 <swtch>:
    800027a0:	00153023          	sd	ra,0(a0)
    800027a4:	00253423          	sd	sp,8(a0)
    800027a8:	e900                	sd	s0,16(a0)
    800027aa:	ed04                	sd	s1,24(a0)
    800027ac:	03253023          	sd	s2,32(a0)
    800027b0:	03353423          	sd	s3,40(a0)
    800027b4:	03453823          	sd	s4,48(a0)
    800027b8:	03553c23          	sd	s5,56(a0)
    800027bc:	05653023          	sd	s6,64(a0)
    800027c0:	05753423          	sd	s7,72(a0)
    800027c4:	05853823          	sd	s8,80(a0)
    800027c8:	05953c23          	sd	s9,88(a0)
    800027cc:	07a53023          	sd	s10,96(a0)
    800027d0:	07b53423          	sd	s11,104(a0)
    800027d4:	0005b083          	ld	ra,0(a1)
    800027d8:	0085b103          	ld	sp,8(a1)
    800027dc:	6980                	ld	s0,16(a1)
    800027de:	6d84                	ld	s1,24(a1)
    800027e0:	0205b903          	ld	s2,32(a1)
    800027e4:	0285b983          	ld	s3,40(a1)
    800027e8:	0305ba03          	ld	s4,48(a1)
    800027ec:	0385ba83          	ld	s5,56(a1)
    800027f0:	0405bb03          	ld	s6,64(a1)
    800027f4:	0485bb83          	ld	s7,72(a1)
    800027f8:	0505bc03          	ld	s8,80(a1)
    800027fc:	0585bc83          	ld	s9,88(a1)
    80002800:	0605bd03          	ld	s10,96(a1)
    80002804:	0685bd83          	ld	s11,104(a1)
    80002808:	8082                	ret

000000008000280a <trapinit>:

extern int devintr();

void
trapinit(void)
{
    8000280a:	1141                	addi	sp,sp,-16
    8000280c:	e406                	sd	ra,8(sp)
    8000280e:	e022                	sd	s0,0(sp)
    80002810:	0800                	addi	s0,sp,16
  initlock(&tickslock, "time");
    80002812:	00006597          	auipc	a1,0x6
    80002816:	cee58593          	addi	a1,a1,-786 # 80008500 <userret+0x470>
    8000281a:	00018517          	auipc	a0,0x18
    8000281e:	15e50513          	addi	a0,a0,350 # 8001a978 <tickslock>
    80002822:	ffffe097          	auipc	ra,0xffffe
    80002826:	2d4080e7          	jalr	724(ra) # 80000af6 <initlock>
}
    8000282a:	60a2                	ld	ra,8(sp)
    8000282c:	6402                	ld	s0,0(sp)
    8000282e:	0141                	addi	sp,sp,16
    80002830:	8082                	ret

0000000080002832 <trapinithart>:

// set up to take exceptions and traps while in the kernel.
void
trapinithart(void)
{
    80002832:	1141                	addi	sp,sp,-16
    80002834:	e422                	sd	s0,8(sp)
    80002836:	0800                	addi	s0,sp,16
  asm volatile("csrw stvec, %0" : : "r" (x));
    80002838:	00003797          	auipc	a5,0x3
    8000283c:	7c878793          	addi	a5,a5,1992 # 80006000 <kernelvec>
    80002840:	10579073          	csrw	stvec,a5
  w_stvec((uint64)kernelvec);
}
    80002844:	6422                	ld	s0,8(sp)
    80002846:	0141                	addi	sp,sp,16
    80002848:	8082                	ret

000000008000284a <usertrapret>:
//
// return to user space
//
void
usertrapret(void)
{
    8000284a:	1141                	addi	sp,sp,-16
    8000284c:	e406                	sd	ra,8(sp)
    8000284e:	e022                	sd	s0,0(sp)
    80002850:	0800                	addi	s0,sp,16
  struct proc *p = myproc();
    80002852:	fffff097          	auipc	ra,0xfffff
    80002856:	3b4080e7          	jalr	948(ra) # 80001c06 <myproc>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    8000285a:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() & ~SSTATUS_SIE);
    8000285e:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002860:	10079073          	csrw	sstatus,a5
  // turn off interrupts, since we're switching
  // now from kerneltrap() to usertrap().
  intr_off();

  // send syscalls, interrupts, and exceptions to trampoline.S
  w_stvec(TRAMPOLINE + (uservec - trampoline));
    80002864:	00005617          	auipc	a2,0x5
    80002868:	79c60613          	addi	a2,a2,1948 # 80008000 <trampoline>
    8000286c:	00005697          	auipc	a3,0x5
    80002870:	79468693          	addi	a3,a3,1940 # 80008000 <trampoline>
    80002874:	8e91                	sub	a3,a3,a2
    80002876:	040007b7          	lui	a5,0x4000
    8000287a:	17fd                	addi	a5,a5,-1
    8000287c:	07b2                	slli	a5,a5,0xc
    8000287e:	96be                	add	a3,a3,a5
  asm volatile("csrw stvec, %0" : : "r" (x));
    80002880:	10569073          	csrw	stvec,a3

  // set up trapframe values that uservec will need when
  // the process next re-enters the kernel.
  p->tf->kernel_satp = r_satp();         // kernel page table
    80002884:	7138                	ld	a4,96(a0)
  asm volatile("csrr %0, satp" : "=r" (x) );
    80002886:	180026f3          	csrr	a3,satp
    8000288a:	e314                	sd	a3,0(a4)
  p->tf->kernel_sp = p->kstack + PGSIZE; // process's kernel stack
    8000288c:	7138                	ld	a4,96(a0)
    8000288e:	6534                	ld	a3,72(a0)
    80002890:	6585                	lui	a1,0x1
    80002892:	96ae                	add	a3,a3,a1
    80002894:	e714                	sd	a3,8(a4)
  p->tf->kernel_trap = (uint64)usertrap;
    80002896:	7138                	ld	a4,96(a0)
    80002898:	00000697          	auipc	a3,0x0
    8000289c:	12868693          	addi	a3,a3,296 # 800029c0 <usertrap>
    800028a0:	eb14                	sd	a3,16(a4)
  p->tf->kernel_hartid = r_tp();         // hartid for cpuid()
    800028a2:	7138                	ld	a4,96(a0)
  asm volatile("mv %0, tp" : "=r" (x) );
    800028a4:	8692                	mv	a3,tp
    800028a6:	f314                	sd	a3,32(a4)
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800028a8:	100026f3          	csrr	a3,sstatus
  // set up the registers that trampoline.S's sret will use
  // to get to user space.
  
  // set S Previous Privilege mode to User.
  unsigned long x = r_sstatus();
  x &= ~SSTATUS_SPP; // clear SPP to 0 for user mode
    800028ac:	eff6f693          	andi	a3,a3,-257
  x |= SSTATUS_SPIE; // enable interrupts in user mode
    800028b0:	0206e693          	ori	a3,a3,32
  asm volatile("csrw sstatus, %0" : : "r" (x));
    800028b4:	10069073          	csrw	sstatus,a3
  w_sstatus(x);

  // set S Exception Program Counter to the saved user pc.
  w_sepc(p->tf->epc);
    800028b8:	7138                	ld	a4,96(a0)
  asm volatile("csrw sepc, %0" : : "r" (x));
    800028ba:	6f18                	ld	a4,24(a4)
    800028bc:	14171073          	csrw	sepc,a4

  // tell trampoline.S the user page table to switch to.
  uint64 satp = MAKE_SATP(p->pagetable);
    800028c0:	6d2c                	ld	a1,88(a0)
    800028c2:	81b1                	srli	a1,a1,0xc

  // jump to trampoline.S at the top of memory, which 
  // switches to the user page table, restores user registers,
  // and switches to user mode with sret.
  uint64 fn = TRAMPOLINE + (userret - trampoline);
    800028c4:	00005717          	auipc	a4,0x5
    800028c8:	7cc70713          	addi	a4,a4,1996 # 80008090 <userret>
    800028cc:	8f11                	sub	a4,a4,a2
    800028ce:	97ba                	add	a5,a5,a4
  ((void (*)(uint64,uint64))fn)(TRAPFRAME, satp);
    800028d0:	577d                	li	a4,-1
    800028d2:	177e                	slli	a4,a4,0x3f
    800028d4:	8dd9                	or	a1,a1,a4
    800028d6:	02000537          	lui	a0,0x2000
    800028da:	157d                	addi	a0,a0,-1
    800028dc:	0536                	slli	a0,a0,0xd
    800028de:	9782                	jalr	a5
}
    800028e0:	60a2                	ld	ra,8(sp)
    800028e2:	6402                	ld	s0,0(sp)
    800028e4:	0141                	addi	sp,sp,16
    800028e6:	8082                	ret

00000000800028e8 <clockintr>:
  w_sstatus(sstatus);
}

void
clockintr()
{
    800028e8:	1101                	addi	sp,sp,-32
    800028ea:	ec06                	sd	ra,24(sp)
    800028ec:	e822                	sd	s0,16(sp)
    800028ee:	e426                	sd	s1,8(sp)
    800028f0:	1000                	addi	s0,sp,32
  acquire(&tickslock);
    800028f2:	00018497          	auipc	s1,0x18
    800028f6:	08648493          	addi	s1,s1,134 # 8001a978 <tickslock>
    800028fa:	8526                	mv	a0,s1
    800028fc:	ffffe097          	auipc	ra,0xffffe
    80002900:	34a080e7          	jalr	842(ra) # 80000c46 <acquire>
  ticks++;
    80002904:	0002d517          	auipc	a0,0x2d
    80002908:	73c50513          	addi	a0,a0,1852 # 80030040 <ticks>
    8000290c:	411c                	lw	a5,0(a0)
    8000290e:	2785                	addiw	a5,a5,1
    80002910:	c11c                	sw	a5,0(a0)
  wakeup(&ticks);
    80002912:	00000097          	auipc	ra,0x0
    80002916:	c56080e7          	jalr	-938(ra) # 80002568 <wakeup>
  release(&tickslock);
    8000291a:	8526                	mv	a0,s1
    8000291c:	ffffe097          	auipc	ra,0xffffe
    80002920:	39a080e7          	jalr	922(ra) # 80000cb6 <release>
}
    80002924:	60e2                	ld	ra,24(sp)
    80002926:	6442                	ld	s0,16(sp)
    80002928:	64a2                	ld	s1,8(sp)
    8000292a:	6105                	addi	sp,sp,32
    8000292c:	8082                	ret

000000008000292e <devintr>:
// returns 2 if timer interrupt,
// 1 if other device,
// 0 if not recognized.
int
devintr()
{
    8000292e:	1101                	addi	sp,sp,-32
    80002930:	ec06                	sd	ra,24(sp)
    80002932:	e822                	sd	s0,16(sp)
    80002934:	e426                	sd	s1,8(sp)
    80002936:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, scause" : "=r" (x) );
    80002938:	14202773          	csrr	a4,scause
  uint64 scause = r_scause();

  if((scause & 0x8000000000000000L) &&
    8000293c:	00074d63          	bltz	a4,80002956 <devintr+0x28>
      virtio_disk_intr(irq - VIRTIO0_IRQ);
    }

    plic_complete(irq);
    return 1;
  } else if(scause == 0x8000000000000001L){
    80002940:	57fd                	li	a5,-1
    80002942:	17fe                	slli	a5,a5,0x3f
    80002944:	0785                	addi	a5,a5,1
    // the SSIP bit in sip.
    w_sip(r_sip() & ~2);

    return 2;
  } else {
    return 0;
    80002946:	4501                	li	a0,0
  } else if(scause == 0x8000000000000001L){
    80002948:	04f70b63          	beq	a4,a5,8000299e <devintr+0x70>
  }
}
    8000294c:	60e2                	ld	ra,24(sp)
    8000294e:	6442                	ld	s0,16(sp)
    80002950:	64a2                	ld	s1,8(sp)
    80002952:	6105                	addi	sp,sp,32
    80002954:	8082                	ret
     (scause & 0xff) == 9){
    80002956:	0ff77793          	andi	a5,a4,255
  if((scause & 0x8000000000000000L) &&
    8000295a:	46a5                	li	a3,9
    8000295c:	fed792e3          	bne	a5,a3,80002940 <devintr+0x12>
    int irq = plic_claim();
    80002960:	00003097          	auipc	ra,0x3
    80002964:	7a8080e7          	jalr	1960(ra) # 80006108 <plic_claim>
    80002968:	84aa                	mv	s1,a0
    if(irq == UART0_IRQ){
    8000296a:	47a9                	li	a5,10
    8000296c:	00f50e63          	beq	a0,a5,80002988 <devintr+0x5a>
    } else if(irq == VIRTIO0_IRQ || irq == VIRTIO1_IRQ ){
    80002970:	fff5079b          	addiw	a5,a0,-1
    80002974:	4705                	li	a4,1
    80002976:	00f77e63          	bleu	a5,a4,80002992 <devintr+0x64>
    plic_complete(irq);
    8000297a:	8526                	mv	a0,s1
    8000297c:	00003097          	auipc	ra,0x3
    80002980:	7b0080e7          	jalr	1968(ra) # 8000612c <plic_complete>
    return 1;
    80002984:	4505                	li	a0,1
    80002986:	b7d9                	j	8000294c <devintr+0x1e>
      uartintr();
    80002988:	ffffe097          	auipc	ra,0xffffe
    8000298c:	ef0080e7          	jalr	-272(ra) # 80000878 <uartintr>
    80002990:	b7ed                	j	8000297a <devintr+0x4c>
      virtio_disk_intr(irq - VIRTIO0_IRQ);
    80002992:	853e                	mv	a0,a5
    80002994:	00004097          	auipc	ra,0x4
    80002998:	d6a080e7          	jalr	-662(ra) # 800066fe <virtio_disk_intr>
    8000299c:	bff9                	j	8000297a <devintr+0x4c>
    if(cpuid() == 0){
    8000299e:	fffff097          	auipc	ra,0xfffff
    800029a2:	23c080e7          	jalr	572(ra) # 80001bda <cpuid>
    800029a6:	c901                	beqz	a0,800029b6 <devintr+0x88>
  asm volatile("csrr %0, sip" : "=r" (x) );
    800029a8:	144027f3          	csrr	a5,sip
    w_sip(r_sip() & ~2);
    800029ac:	9bf5                	andi	a5,a5,-3
  asm volatile("csrw sip, %0" : : "r" (x));
    800029ae:	14479073          	csrw	sip,a5
    return 2;
    800029b2:	4509                	li	a0,2
    800029b4:	bf61                	j	8000294c <devintr+0x1e>
      clockintr();
    800029b6:	00000097          	auipc	ra,0x0
    800029ba:	f32080e7          	jalr	-206(ra) # 800028e8 <clockintr>
    800029be:	b7ed                	j	800029a8 <devintr+0x7a>

00000000800029c0 <usertrap>:
{
    800029c0:	1101                	addi	sp,sp,-32
    800029c2:	ec06                	sd	ra,24(sp)
    800029c4:	e822                	sd	s0,16(sp)
    800029c6:	e426                	sd	s1,8(sp)
    800029c8:	e04a                	sd	s2,0(sp)
    800029ca:	1000                	addi	s0,sp,32
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    800029cc:	100027f3          	csrr	a5,sstatus
  if((r_sstatus() & SSTATUS_SPP) != 0)
    800029d0:	1007f793          	andi	a5,a5,256
    800029d4:	e7bd                	bnez	a5,80002a42 <usertrap+0x82>
  asm volatile("csrw stvec, %0" : : "r" (x));
    800029d6:	00003797          	auipc	a5,0x3
    800029da:	62a78793          	addi	a5,a5,1578 # 80006000 <kernelvec>
    800029de:	10579073          	csrw	stvec,a5
  struct proc *p = myproc();
    800029e2:	fffff097          	auipc	ra,0xfffff
    800029e6:	224080e7          	jalr	548(ra) # 80001c06 <myproc>
    800029ea:	84aa                	mv	s1,a0
  p->tf->epc = r_sepc();
    800029ec:	713c                	ld	a5,96(a0)
  asm volatile("csrr %0, sepc" : "=r" (x) );
    800029ee:	14102773          	csrr	a4,sepc
    800029f2:	ef98                	sd	a4,24(a5)
  asm volatile("csrr %0, scause" : "=r" (x) );
    800029f4:	14202773          	csrr	a4,scause
  if(r_scause() == 8){
    800029f8:	47a1                	li	a5,8
    800029fa:	06f71263          	bne	a4,a5,80002a5e <usertrap+0x9e>
    if(p->killed)
    800029fe:	5d1c                	lw	a5,56(a0)
    80002a00:	eba9                	bnez	a5,80002a52 <usertrap+0x92>
    p->tf->epc += 4;
    80002a02:	70b8                	ld	a4,96(s1)
    80002a04:	6f1c                	ld	a5,24(a4)
    80002a06:	0791                	addi	a5,a5,4
    80002a08:	ef1c                	sd	a5,24(a4)
  asm volatile("csrr %0, sie" : "=r" (x) );
    80002a0a:	104027f3          	csrr	a5,sie
  w_sie(r_sie() | SIE_SEIE | SIE_STIE | SIE_SSIE);
    80002a0e:	2227e793          	ori	a5,a5,546
  asm volatile("csrw sie, %0" : : "r" (x));
    80002a12:	10479073          	csrw	sie,a5
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002a16:	100027f3          	csrr	a5,sstatus
  w_sstatus(r_sstatus() | SSTATUS_SIE);
    80002a1a:	0027e793          	ori	a5,a5,2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002a1e:	10079073          	csrw	sstatus,a5
    syscall();
    80002a22:	00000097          	auipc	ra,0x0
    80002a26:	2e6080e7          	jalr	742(ra) # 80002d08 <syscall>
  if(p->killed)
    80002a2a:	5c9c                	lw	a5,56(s1)
    80002a2c:	ebc1                	bnez	a5,80002abc <usertrap+0xfc>
  usertrapret();
    80002a2e:	00000097          	auipc	ra,0x0
    80002a32:	e1c080e7          	jalr	-484(ra) # 8000284a <usertrapret>
}
    80002a36:	60e2                	ld	ra,24(sp)
    80002a38:	6442                	ld	s0,16(sp)
    80002a3a:	64a2                	ld	s1,8(sp)
    80002a3c:	6902                	ld	s2,0(sp)
    80002a3e:	6105                	addi	sp,sp,32
    80002a40:	8082                	ret
    panic("usertrap: not from user mode");
    80002a42:	00006517          	auipc	a0,0x6
    80002a46:	ac650513          	addi	a0,a0,-1338 # 80008508 <userret+0x478>
    80002a4a:	ffffe097          	auipc	ra,0xffffe
    80002a4e:	b34080e7          	jalr	-1228(ra) # 8000057e <panic>
      exit(-1);
    80002a52:	557d                	li	a0,-1
    80002a54:	00000097          	auipc	ra,0x0
    80002a58:	842080e7          	jalr	-1982(ra) # 80002296 <exit>
    80002a5c:	b75d                	j	80002a02 <usertrap+0x42>
  } else if((which_dev = devintr()) != 0){
    80002a5e:	00000097          	auipc	ra,0x0
    80002a62:	ed0080e7          	jalr	-304(ra) # 8000292e <devintr>
    80002a66:	892a                	mv	s2,a0
    80002a68:	c501                	beqz	a0,80002a70 <usertrap+0xb0>
  if(p->killed)
    80002a6a:	5c9c                	lw	a5,56(s1)
    80002a6c:	c3a1                	beqz	a5,80002aac <usertrap+0xec>
    80002a6e:	a815                	j	80002aa2 <usertrap+0xe2>
  asm volatile("csrr %0, scause" : "=r" (x) );
    80002a70:	142025f3          	csrr	a1,scause
    printf("usertrap(): unexpected scause %p pid=%d\n", r_scause(), p->pid);
    80002a74:	40b0                	lw	a2,64(s1)
    80002a76:	00006517          	auipc	a0,0x6
    80002a7a:	ab250513          	addi	a0,a0,-1358 # 80008528 <userret+0x498>
    80002a7e:	ffffe097          	auipc	ra,0xffffe
    80002a82:	b5a080e7          	jalr	-1190(ra) # 800005d8 <printf>
  asm volatile("csrr %0, sepc" : "=r" (x) );
    80002a86:	141025f3          	csrr	a1,sepc
  asm volatile("csrr %0, stval" : "=r" (x) );
    80002a8a:	14302673          	csrr	a2,stval
    printf("            sepc=%p stval=%p\n", r_sepc(), r_stval());
    80002a8e:	00006517          	auipc	a0,0x6
    80002a92:	aca50513          	addi	a0,a0,-1334 # 80008558 <userret+0x4c8>
    80002a96:	ffffe097          	auipc	ra,0xffffe
    80002a9a:	b42080e7          	jalr	-1214(ra) # 800005d8 <printf>
    p->killed = 1;
    80002a9e:	4785                	li	a5,1
    80002aa0:	dc9c                	sw	a5,56(s1)
    exit(-1);
    80002aa2:	557d                	li	a0,-1
    80002aa4:	fffff097          	auipc	ra,0xfffff
    80002aa8:	7f2080e7          	jalr	2034(ra) # 80002296 <exit>
  if(which_dev == 2)
    80002aac:	4789                	li	a5,2
    80002aae:	f8f910e3          	bne	s2,a5,80002a2e <usertrap+0x6e>
    yield();
    80002ab2:	00000097          	auipc	ra,0x0
    80002ab6:	8f4080e7          	jalr	-1804(ra) # 800023a6 <yield>
    80002aba:	bf95                	j	80002a2e <usertrap+0x6e>
  int which_dev = 0;
    80002abc:	4901                	li	s2,0
    80002abe:	b7d5                	j	80002aa2 <usertrap+0xe2>

0000000080002ac0 <kerneltrap>:
{
    80002ac0:	7179                	addi	sp,sp,-48
    80002ac2:	f406                	sd	ra,40(sp)
    80002ac4:	f022                	sd	s0,32(sp)
    80002ac6:	ec26                	sd	s1,24(sp)
    80002ac8:	e84a                	sd	s2,16(sp)
    80002aca:	e44e                	sd	s3,8(sp)
    80002acc:	1800                	addi	s0,sp,48
  asm volatile("csrr %0, sepc" : "=r" (x) );
    80002ace:	14102973          	csrr	s2,sepc
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002ad2:	100024f3          	csrr	s1,sstatus
  asm volatile("csrr %0, scause" : "=r" (x) );
    80002ad6:	142029f3          	csrr	s3,scause
  if((sstatus & SSTATUS_SPP) == 0)
    80002ada:	1004f793          	andi	a5,s1,256
    80002ade:	cb85                	beqz	a5,80002b0e <kerneltrap+0x4e>
  asm volatile("csrr %0, sstatus" : "=r" (x) );
    80002ae0:	100027f3          	csrr	a5,sstatus
  return (x & SSTATUS_SIE) != 0;
    80002ae4:	8b89                	andi	a5,a5,2
  if(intr_get() != 0)
    80002ae6:	ef85                	bnez	a5,80002b1e <kerneltrap+0x5e>
  if((which_dev = devintr()) == 0){
    80002ae8:	00000097          	auipc	ra,0x0
    80002aec:	e46080e7          	jalr	-442(ra) # 8000292e <devintr>
    80002af0:	cd1d                	beqz	a0,80002b2e <kerneltrap+0x6e>
  if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING)
    80002af2:	4789                	li	a5,2
    80002af4:	06f50a63          	beq	a0,a5,80002b68 <kerneltrap+0xa8>
  asm volatile("csrw sepc, %0" : : "r" (x));
    80002af8:	14191073          	csrw	sepc,s2
  asm volatile("csrw sstatus, %0" : : "r" (x));
    80002afc:	10049073          	csrw	sstatus,s1
}
    80002b00:	70a2                	ld	ra,40(sp)
    80002b02:	7402                	ld	s0,32(sp)
    80002b04:	64e2                	ld	s1,24(sp)
    80002b06:	6942                	ld	s2,16(sp)
    80002b08:	69a2                	ld	s3,8(sp)
    80002b0a:	6145                	addi	sp,sp,48
    80002b0c:	8082                	ret
    panic("kerneltrap: not from supervisor mode");
    80002b0e:	00006517          	auipc	a0,0x6
    80002b12:	a6a50513          	addi	a0,a0,-1430 # 80008578 <userret+0x4e8>
    80002b16:	ffffe097          	auipc	ra,0xffffe
    80002b1a:	a68080e7          	jalr	-1432(ra) # 8000057e <panic>
    panic("kerneltrap: interrupts enabled");
    80002b1e:	00006517          	auipc	a0,0x6
    80002b22:	a8250513          	addi	a0,a0,-1406 # 800085a0 <userret+0x510>
    80002b26:	ffffe097          	auipc	ra,0xffffe
    80002b2a:	a58080e7          	jalr	-1448(ra) # 8000057e <panic>
    printf("scause %p\n", scause);
    80002b2e:	85ce                	mv	a1,s3
    80002b30:	00006517          	auipc	a0,0x6
    80002b34:	a9050513          	addi	a0,a0,-1392 # 800085c0 <userret+0x530>
    80002b38:	ffffe097          	auipc	ra,0xffffe
    80002b3c:	aa0080e7          	jalr	-1376(ra) # 800005d8 <printf>
  asm volatile("csrr %0, sepc" : "=r" (x) );
    80002b40:	141025f3          	csrr	a1,sepc
  asm volatile("csrr %0, stval" : "=r" (x) );
    80002b44:	14302673          	csrr	a2,stval
    printf("sepc=%p stval=%p\n", r_sepc(), r_stval());
    80002b48:	00006517          	auipc	a0,0x6
    80002b4c:	a8850513          	addi	a0,a0,-1400 # 800085d0 <userret+0x540>
    80002b50:	ffffe097          	auipc	ra,0xffffe
    80002b54:	a88080e7          	jalr	-1400(ra) # 800005d8 <printf>
    panic("kerneltrap");
    80002b58:	00006517          	auipc	a0,0x6
    80002b5c:	a9050513          	addi	a0,a0,-1392 # 800085e8 <userret+0x558>
    80002b60:	ffffe097          	auipc	ra,0xffffe
    80002b64:	a1e080e7          	jalr	-1506(ra) # 8000057e <panic>
  if(which_dev == 2 && myproc() != 0 && myproc()->state == RUNNING)
    80002b68:	fffff097          	auipc	ra,0xfffff
    80002b6c:	09e080e7          	jalr	158(ra) # 80001c06 <myproc>
    80002b70:	d541                	beqz	a0,80002af8 <kerneltrap+0x38>
    80002b72:	fffff097          	auipc	ra,0xfffff
    80002b76:	094080e7          	jalr	148(ra) # 80001c06 <myproc>
    80002b7a:	5118                	lw	a4,32(a0)
    80002b7c:	478d                	li	a5,3
    80002b7e:	f6f71de3          	bne	a4,a5,80002af8 <kerneltrap+0x38>
    yield();
    80002b82:	00000097          	auipc	ra,0x0
    80002b86:	824080e7          	jalr	-2012(ra) # 800023a6 <yield>
    80002b8a:	b7bd                	j	80002af8 <kerneltrap+0x38>

0000000080002b8c <argraw>:
  return strlen(buf);
}

static uint64
argraw(int n)
{
    80002b8c:	1101                	addi	sp,sp,-32
    80002b8e:	ec06                	sd	ra,24(sp)
    80002b90:	e822                	sd	s0,16(sp)
    80002b92:	e426                	sd	s1,8(sp)
    80002b94:	1000                	addi	s0,sp,32
    80002b96:	84aa                	mv	s1,a0
  struct proc *p = myproc();
    80002b98:	fffff097          	auipc	ra,0xfffff
    80002b9c:	06e080e7          	jalr	110(ra) # 80001c06 <myproc>
  switch (n) {
    80002ba0:	4795                	li	a5,5
    80002ba2:	0497e363          	bltu	a5,s1,80002be8 <argraw+0x5c>
    80002ba6:	1482                	slli	s1,s1,0x20
    80002ba8:	9081                	srli	s1,s1,0x20
    80002baa:	048a                	slli	s1,s1,0x2
    80002bac:	00006717          	auipc	a4,0x6
    80002bb0:	f5470713          	addi	a4,a4,-172 # 80008b00 <states.1805+0x28>
    80002bb4:	94ba                	add	s1,s1,a4
    80002bb6:	409c                	lw	a5,0(s1)
    80002bb8:	97ba                	add	a5,a5,a4
    80002bba:	8782                	jr	a5
  case 0:
    return p->tf->a0;
    80002bbc:	713c                	ld	a5,96(a0)
    80002bbe:	7ba8                	ld	a0,112(a5)
  case 5:
    return p->tf->a5;
  }
  panic("argraw");
  return -1;
}
    80002bc0:	60e2                	ld	ra,24(sp)
    80002bc2:	6442                	ld	s0,16(sp)
    80002bc4:	64a2                	ld	s1,8(sp)
    80002bc6:	6105                	addi	sp,sp,32
    80002bc8:	8082                	ret
    return p->tf->a1;
    80002bca:	713c                	ld	a5,96(a0)
    80002bcc:	7fa8                	ld	a0,120(a5)
    80002bce:	bfcd                	j	80002bc0 <argraw+0x34>
    return p->tf->a2;
    80002bd0:	713c                	ld	a5,96(a0)
    80002bd2:	63c8                	ld	a0,128(a5)
    80002bd4:	b7f5                	j	80002bc0 <argraw+0x34>
    return p->tf->a3;
    80002bd6:	713c                	ld	a5,96(a0)
    80002bd8:	67c8                	ld	a0,136(a5)
    80002bda:	b7dd                	j	80002bc0 <argraw+0x34>
    return p->tf->a4;
    80002bdc:	713c                	ld	a5,96(a0)
    80002bde:	6bc8                	ld	a0,144(a5)
    80002be0:	b7c5                	j	80002bc0 <argraw+0x34>
    return p->tf->a5;
    80002be2:	713c                	ld	a5,96(a0)
    80002be4:	6fc8                	ld	a0,152(a5)
    80002be6:	bfe9                	j	80002bc0 <argraw+0x34>
  panic("argraw");
    80002be8:	00006517          	auipc	a0,0x6
    80002bec:	a1050513          	addi	a0,a0,-1520 # 800085f8 <userret+0x568>
    80002bf0:	ffffe097          	auipc	ra,0xffffe
    80002bf4:	98e080e7          	jalr	-1650(ra) # 8000057e <panic>

0000000080002bf8 <fetchaddr>:
{
    80002bf8:	1101                	addi	sp,sp,-32
    80002bfa:	ec06                	sd	ra,24(sp)
    80002bfc:	e822                	sd	s0,16(sp)
    80002bfe:	e426                	sd	s1,8(sp)
    80002c00:	e04a                	sd	s2,0(sp)
    80002c02:	1000                	addi	s0,sp,32
    80002c04:	84aa                	mv	s1,a0
    80002c06:	892e                	mv	s2,a1
  struct proc *p = myproc();
    80002c08:	fffff097          	auipc	ra,0xfffff
    80002c0c:	ffe080e7          	jalr	-2(ra) # 80001c06 <myproc>
  if(addr >= p->sz || addr+sizeof(uint64) > p->sz)
    80002c10:	693c                	ld	a5,80(a0)
    80002c12:	02f4f963          	bleu	a5,s1,80002c44 <fetchaddr+0x4c>
    80002c16:	00848713          	addi	a4,s1,8
    80002c1a:	02e7e763          	bltu	a5,a4,80002c48 <fetchaddr+0x50>
  if(copyin(p->pagetable, (char *)ip, addr, sizeof(*ip)) != 0)
    80002c1e:	46a1                	li	a3,8
    80002c20:	8626                	mv	a2,s1
    80002c22:	85ca                	mv	a1,s2
    80002c24:	6d28                	ld	a0,88(a0)
    80002c26:	fffff097          	auipc	ra,0xfffff
    80002c2a:	d48080e7          	jalr	-696(ra) # 8000196e <copyin>
    80002c2e:	00a03533          	snez	a0,a0
    80002c32:	40a0053b          	negw	a0,a0
    80002c36:	2501                	sext.w	a0,a0
}
    80002c38:	60e2                	ld	ra,24(sp)
    80002c3a:	6442                	ld	s0,16(sp)
    80002c3c:	64a2                	ld	s1,8(sp)
    80002c3e:	6902                	ld	s2,0(sp)
    80002c40:	6105                	addi	sp,sp,32
    80002c42:	8082                	ret
    return -1;
    80002c44:	557d                	li	a0,-1
    80002c46:	bfcd                	j	80002c38 <fetchaddr+0x40>
    80002c48:	557d                	li	a0,-1
    80002c4a:	b7fd                	j	80002c38 <fetchaddr+0x40>

0000000080002c4c <fetchstr>:
{
    80002c4c:	7179                	addi	sp,sp,-48
    80002c4e:	f406                	sd	ra,40(sp)
    80002c50:	f022                	sd	s0,32(sp)
    80002c52:	ec26                	sd	s1,24(sp)
    80002c54:	e84a                	sd	s2,16(sp)
    80002c56:	e44e                	sd	s3,8(sp)
    80002c58:	1800                	addi	s0,sp,48
    80002c5a:	892a                	mv	s2,a0
    80002c5c:	84ae                	mv	s1,a1
    80002c5e:	89b2                	mv	s3,a2
  struct proc *p = myproc();
    80002c60:	fffff097          	auipc	ra,0xfffff
    80002c64:	fa6080e7          	jalr	-90(ra) # 80001c06 <myproc>
  int err = copyinstr(p->pagetable, buf, addr, max);
    80002c68:	86ce                	mv	a3,s3
    80002c6a:	864a                	mv	a2,s2
    80002c6c:	85a6                	mv	a1,s1
    80002c6e:	6d28                	ld	a0,88(a0)
    80002c70:	fffff097          	auipc	ra,0xfffff
    80002c74:	d8c080e7          	jalr	-628(ra) # 800019fc <copyinstr>
  if(err < 0)
    80002c78:	00054763          	bltz	a0,80002c86 <fetchstr+0x3a>
  return strlen(buf);
    80002c7c:	8526                	mv	a0,s1
    80002c7e:	ffffe097          	auipc	ra,0xffffe
    80002c82:	408080e7          	jalr	1032(ra) # 80001086 <strlen>
}
    80002c86:	70a2                	ld	ra,40(sp)
    80002c88:	7402                	ld	s0,32(sp)
    80002c8a:	64e2                	ld	s1,24(sp)
    80002c8c:	6942                	ld	s2,16(sp)
    80002c8e:	69a2                	ld	s3,8(sp)
    80002c90:	6145                	addi	sp,sp,48
    80002c92:	8082                	ret

0000000080002c94 <argint>:

// Fetch the nth 32-bit system call argument.
int
argint(int n, int *ip)
{
    80002c94:	1101                	addi	sp,sp,-32
    80002c96:	ec06                	sd	ra,24(sp)
    80002c98:	e822                	sd	s0,16(sp)
    80002c9a:	e426                	sd	s1,8(sp)
    80002c9c:	1000                	addi	s0,sp,32
    80002c9e:	84ae                	mv	s1,a1
  *ip = argraw(n);
    80002ca0:	00000097          	auipc	ra,0x0
    80002ca4:	eec080e7          	jalr	-276(ra) # 80002b8c <argraw>
    80002ca8:	c088                	sw	a0,0(s1)
  return 0;
}
    80002caa:	4501                	li	a0,0
    80002cac:	60e2                	ld	ra,24(sp)
    80002cae:	6442                	ld	s0,16(sp)
    80002cb0:	64a2                	ld	s1,8(sp)
    80002cb2:	6105                	addi	sp,sp,32
    80002cb4:	8082                	ret

0000000080002cb6 <argaddr>:
// Retrieve an argument as a pointer.
// Doesn't check for legality, since
// copyin/copyout will do that.
int
argaddr(int n, uint64 *ip)
{
    80002cb6:	1101                	addi	sp,sp,-32
    80002cb8:	ec06                	sd	ra,24(sp)
    80002cba:	e822                	sd	s0,16(sp)
    80002cbc:	e426                	sd	s1,8(sp)
    80002cbe:	1000                	addi	s0,sp,32
    80002cc0:	84ae                	mv	s1,a1
  *ip = argraw(n);
    80002cc2:	00000097          	auipc	ra,0x0
    80002cc6:	eca080e7          	jalr	-310(ra) # 80002b8c <argraw>
    80002cca:	e088                	sd	a0,0(s1)
  return 0;
}
    80002ccc:	4501                	li	a0,0
    80002cce:	60e2                	ld	ra,24(sp)
    80002cd0:	6442                	ld	s0,16(sp)
    80002cd2:	64a2                	ld	s1,8(sp)
    80002cd4:	6105                	addi	sp,sp,32
    80002cd6:	8082                	ret

0000000080002cd8 <argstr>:
// Fetch the nth word-sized system call argument as a null-terminated string.
// Copies into buf, at most max.
// Returns string length if OK (including nul), -1 if error.
int
argstr(int n, char *buf, int max)
{
    80002cd8:	1101                	addi	sp,sp,-32
    80002cda:	ec06                	sd	ra,24(sp)
    80002cdc:	e822                	sd	s0,16(sp)
    80002cde:	e426                	sd	s1,8(sp)
    80002ce0:	e04a                	sd	s2,0(sp)
    80002ce2:	1000                	addi	s0,sp,32
    80002ce4:	84ae                	mv	s1,a1
    80002ce6:	8932                	mv	s2,a2
  *ip = argraw(n);
    80002ce8:	00000097          	auipc	ra,0x0
    80002cec:	ea4080e7          	jalr	-348(ra) # 80002b8c <argraw>
  uint64 addr;
  if(argaddr(n, &addr) < 0)
    return -1;
  return fetchstr(addr, buf, max);
    80002cf0:	864a                	mv	a2,s2
    80002cf2:	85a6                	mv	a1,s1
    80002cf4:	00000097          	auipc	ra,0x0
    80002cf8:	f58080e7          	jalr	-168(ra) # 80002c4c <fetchstr>
}
    80002cfc:	60e2                	ld	ra,24(sp)
    80002cfe:	6442                	ld	s0,16(sp)
    80002d00:	64a2                	ld	s1,8(sp)
    80002d02:	6902                	ld	s2,0(sp)
    80002d04:	6105                	addi	sp,sp,32
    80002d06:	8082                	ret

0000000080002d08 <syscall>:
[SYS_ntas]    sys_ntas,
};

void
syscall(void)
{
    80002d08:	1101                	addi	sp,sp,-32
    80002d0a:	ec06                	sd	ra,24(sp)
    80002d0c:	e822                	sd	s0,16(sp)
    80002d0e:	e426                	sd	s1,8(sp)
    80002d10:	e04a                	sd	s2,0(sp)
    80002d12:	1000                	addi	s0,sp,32
  int num;
  struct proc *p = myproc();
    80002d14:	fffff097          	auipc	ra,0xfffff
    80002d18:	ef2080e7          	jalr	-270(ra) # 80001c06 <myproc>
    80002d1c:	84aa                	mv	s1,a0

  num = p->tf->a7;
    80002d1e:	06053903          	ld	s2,96(a0)
    80002d22:	0a893783          	ld	a5,168(s2)
    80002d26:	0007869b          	sext.w	a3,a5
  if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
    80002d2a:	37fd                	addiw	a5,a5,-1
    80002d2c:	4755                	li	a4,21
    80002d2e:	00f76f63          	bltu	a4,a5,80002d4c <syscall+0x44>
    80002d32:	00369713          	slli	a4,a3,0x3
    80002d36:	00006797          	auipc	a5,0x6
    80002d3a:	de278793          	addi	a5,a5,-542 # 80008b18 <syscalls>
    80002d3e:	97ba                	add	a5,a5,a4
    80002d40:	639c                	ld	a5,0(a5)
    80002d42:	c789                	beqz	a5,80002d4c <syscall+0x44>
    p->tf->a0 = syscalls[num]();
    80002d44:	9782                	jalr	a5
    80002d46:	06a93823          	sd	a0,112(s2)
    80002d4a:	a839                	j	80002d68 <syscall+0x60>
  } else {
    printf("%d %s: unknown sys call %d\n",
    80002d4c:	16048613          	addi	a2,s1,352
    80002d50:	40ac                	lw	a1,64(s1)
    80002d52:	00006517          	auipc	a0,0x6
    80002d56:	8ae50513          	addi	a0,a0,-1874 # 80008600 <userret+0x570>
    80002d5a:	ffffe097          	auipc	ra,0xffffe
    80002d5e:	87e080e7          	jalr	-1922(ra) # 800005d8 <printf>
            p->pid, p->name, num);
    p->tf->a0 = -1;
    80002d62:	70bc                	ld	a5,96(s1)
    80002d64:	577d                	li	a4,-1
    80002d66:	fbb8                	sd	a4,112(a5)
  }
}
    80002d68:	60e2                	ld	ra,24(sp)
    80002d6a:	6442                	ld	s0,16(sp)
    80002d6c:	64a2                	ld	s1,8(sp)
    80002d6e:	6902                	ld	s2,0(sp)
    80002d70:	6105                	addi	sp,sp,32
    80002d72:	8082                	ret

0000000080002d74 <sys_exit>:
#include "spinlock.h"
#include "proc.h"

uint64
sys_exit(void)
{
    80002d74:	1101                	addi	sp,sp,-32
    80002d76:	ec06                	sd	ra,24(sp)
    80002d78:	e822                	sd	s0,16(sp)
    80002d7a:	1000                	addi	s0,sp,32
  int n;
  if(argint(0, &n) < 0)
    80002d7c:	fec40593          	addi	a1,s0,-20
    80002d80:	4501                	li	a0,0
    80002d82:	00000097          	auipc	ra,0x0
    80002d86:	f12080e7          	jalr	-238(ra) # 80002c94 <argint>
    return -1;
    80002d8a:	57fd                	li	a5,-1
  if(argint(0, &n) < 0)
    80002d8c:	00054963          	bltz	a0,80002d9e <sys_exit+0x2a>
  exit(n);
    80002d90:	fec42503          	lw	a0,-20(s0)
    80002d94:	fffff097          	auipc	ra,0xfffff
    80002d98:	502080e7          	jalr	1282(ra) # 80002296 <exit>
  return 0;  // not reached
    80002d9c:	4781                	li	a5,0
}
    80002d9e:	853e                	mv	a0,a5
    80002da0:	60e2                	ld	ra,24(sp)
    80002da2:	6442                	ld	s0,16(sp)
    80002da4:	6105                	addi	sp,sp,32
    80002da6:	8082                	ret

0000000080002da8 <sys_getpid>:

uint64
sys_getpid(void)
{
    80002da8:	1141                	addi	sp,sp,-16
    80002daa:	e406                	sd	ra,8(sp)
    80002dac:	e022                	sd	s0,0(sp)
    80002dae:	0800                	addi	s0,sp,16
  return myproc()->pid;
    80002db0:	fffff097          	auipc	ra,0xfffff
    80002db4:	e56080e7          	jalr	-426(ra) # 80001c06 <myproc>
}
    80002db8:	4128                	lw	a0,64(a0)
    80002dba:	60a2                	ld	ra,8(sp)
    80002dbc:	6402                	ld	s0,0(sp)
    80002dbe:	0141                	addi	sp,sp,16
    80002dc0:	8082                	ret

0000000080002dc2 <sys_fork>:

uint64
sys_fork(void)
{
    80002dc2:	1141                	addi	sp,sp,-16
    80002dc4:	e406                	sd	ra,8(sp)
    80002dc6:	e022                	sd	s0,0(sp)
    80002dc8:	0800                	addi	s0,sp,16
  return fork();
    80002dca:	fffff097          	auipc	ra,0xfffff
    80002dce:	1ac080e7          	jalr	428(ra) # 80001f76 <fork>
}
    80002dd2:	60a2                	ld	ra,8(sp)
    80002dd4:	6402                	ld	s0,0(sp)
    80002dd6:	0141                	addi	sp,sp,16
    80002dd8:	8082                	ret

0000000080002dda <sys_wait>:

uint64
sys_wait(void)
{
    80002dda:	1101                	addi	sp,sp,-32
    80002ddc:	ec06                	sd	ra,24(sp)
    80002dde:	e822                	sd	s0,16(sp)
    80002de0:	1000                	addi	s0,sp,32
  uint64 p;
  if(argaddr(0, &p) < 0)
    80002de2:	fe840593          	addi	a1,s0,-24
    80002de6:	4501                	li	a0,0
    80002de8:	00000097          	auipc	ra,0x0
    80002dec:	ece080e7          	jalr	-306(ra) # 80002cb6 <argaddr>
    return -1;
    80002df0:	57fd                	li	a5,-1
  if(argaddr(0, &p) < 0)
    80002df2:	00054963          	bltz	a0,80002e04 <sys_wait+0x2a>
  return wait(p);
    80002df6:	fe843503          	ld	a0,-24(s0)
    80002dfa:	fffff097          	auipc	ra,0xfffff
    80002dfe:	666080e7          	jalr	1638(ra) # 80002460 <wait>
    80002e02:	87aa                	mv	a5,a0
}
    80002e04:	853e                	mv	a0,a5
    80002e06:	60e2                	ld	ra,24(sp)
    80002e08:	6442                	ld	s0,16(sp)
    80002e0a:	6105                	addi	sp,sp,32
    80002e0c:	8082                	ret

0000000080002e0e <sys_sbrk>:

uint64
sys_sbrk(void)
{
    80002e0e:	7179                	addi	sp,sp,-48
    80002e10:	f406                	sd	ra,40(sp)
    80002e12:	f022                	sd	s0,32(sp)
    80002e14:	ec26                	sd	s1,24(sp)
    80002e16:	1800                	addi	s0,sp,48
  int addr;
  int n;

  if(argint(0, &n) < 0)
    80002e18:	fdc40593          	addi	a1,s0,-36
    80002e1c:	4501                	li	a0,0
    80002e1e:	00000097          	auipc	ra,0x0
    80002e22:	e76080e7          	jalr	-394(ra) # 80002c94 <argint>
    return -1;
    80002e26:	54fd                	li	s1,-1
  if(argint(0, &n) < 0)
    80002e28:	00054f63          	bltz	a0,80002e46 <sys_sbrk+0x38>
  addr = myproc()->sz;
    80002e2c:	fffff097          	auipc	ra,0xfffff
    80002e30:	dda080e7          	jalr	-550(ra) # 80001c06 <myproc>
    80002e34:	4924                	lw	s1,80(a0)
  if(growproc(n) < 0)
    80002e36:	fdc42503          	lw	a0,-36(s0)
    80002e3a:	fffff097          	auipc	ra,0xfffff
    80002e3e:	0c4080e7          	jalr	196(ra) # 80001efe <growproc>
    80002e42:	00054863          	bltz	a0,80002e52 <sys_sbrk+0x44>
    return -1;
  return addr;
}
    80002e46:	8526                	mv	a0,s1
    80002e48:	70a2                	ld	ra,40(sp)
    80002e4a:	7402                	ld	s0,32(sp)
    80002e4c:	64e2                	ld	s1,24(sp)
    80002e4e:	6145                	addi	sp,sp,48
    80002e50:	8082                	ret
    return -1;
    80002e52:	54fd                	li	s1,-1
    80002e54:	bfcd                	j	80002e46 <sys_sbrk+0x38>

0000000080002e56 <sys_sleep>:

uint64
sys_sleep(void)
{
    80002e56:	7139                	addi	sp,sp,-64
    80002e58:	fc06                	sd	ra,56(sp)
    80002e5a:	f822                	sd	s0,48(sp)
    80002e5c:	f426                	sd	s1,40(sp)
    80002e5e:	f04a                	sd	s2,32(sp)
    80002e60:	ec4e                	sd	s3,24(sp)
    80002e62:	0080                	addi	s0,sp,64
  int n;
  uint ticks0;

  if(argint(0, &n) < 0)
    80002e64:	fcc40593          	addi	a1,s0,-52
    80002e68:	4501                	li	a0,0
    80002e6a:	00000097          	auipc	ra,0x0
    80002e6e:	e2a080e7          	jalr	-470(ra) # 80002c94 <argint>
    return -1;
    80002e72:	57fd                	li	a5,-1
  if(argint(0, &n) < 0)
    80002e74:	06054763          	bltz	a0,80002ee2 <sys_sleep+0x8c>
  acquire(&tickslock);
    80002e78:	00018517          	auipc	a0,0x18
    80002e7c:	b0050513          	addi	a0,a0,-1280 # 8001a978 <tickslock>
    80002e80:	ffffe097          	auipc	ra,0xffffe
    80002e84:	dc6080e7          	jalr	-570(ra) # 80000c46 <acquire>
  ticks0 = ticks;
    80002e88:	0002d797          	auipc	a5,0x2d
    80002e8c:	1b878793          	addi	a5,a5,440 # 80030040 <ticks>
    80002e90:	0007a903          	lw	s2,0(a5)
  while(ticks - ticks0 < n){
    80002e94:	fcc42783          	lw	a5,-52(s0)
    80002e98:	cf85                	beqz	a5,80002ed0 <sys_sleep+0x7a>
    if(myproc()->killed){
      release(&tickslock);
      return -1;
    }
    sleep(&ticks, &tickslock);
    80002e9a:	00018997          	auipc	s3,0x18
    80002e9e:	ade98993          	addi	s3,s3,-1314 # 8001a978 <tickslock>
    80002ea2:	0002d497          	auipc	s1,0x2d
    80002ea6:	19e48493          	addi	s1,s1,414 # 80030040 <ticks>
    if(myproc()->killed){
    80002eaa:	fffff097          	auipc	ra,0xfffff
    80002eae:	d5c080e7          	jalr	-676(ra) # 80001c06 <myproc>
    80002eb2:	5d1c                	lw	a5,56(a0)
    80002eb4:	ef9d                	bnez	a5,80002ef2 <sys_sleep+0x9c>
    sleep(&ticks, &tickslock);
    80002eb6:	85ce                	mv	a1,s3
    80002eb8:	8526                	mv	a0,s1
    80002eba:	fffff097          	auipc	ra,0xfffff
    80002ebe:	528080e7          	jalr	1320(ra) # 800023e2 <sleep>
  while(ticks - ticks0 < n){
    80002ec2:	409c                	lw	a5,0(s1)
    80002ec4:	412787bb          	subw	a5,a5,s2
    80002ec8:	fcc42703          	lw	a4,-52(s0)
    80002ecc:	fce7efe3          	bltu	a5,a4,80002eaa <sys_sleep+0x54>
  }
  release(&tickslock);
    80002ed0:	00018517          	auipc	a0,0x18
    80002ed4:	aa850513          	addi	a0,a0,-1368 # 8001a978 <tickslock>
    80002ed8:	ffffe097          	auipc	ra,0xffffe
    80002edc:	dde080e7          	jalr	-546(ra) # 80000cb6 <release>
  return 0;
    80002ee0:	4781                	li	a5,0
}
    80002ee2:	853e                	mv	a0,a5
    80002ee4:	70e2                	ld	ra,56(sp)
    80002ee6:	7442                	ld	s0,48(sp)
    80002ee8:	74a2                	ld	s1,40(sp)
    80002eea:	7902                	ld	s2,32(sp)
    80002eec:	69e2                	ld	s3,24(sp)
    80002eee:	6121                	addi	sp,sp,64
    80002ef0:	8082                	ret
      release(&tickslock);
    80002ef2:	00018517          	auipc	a0,0x18
    80002ef6:	a8650513          	addi	a0,a0,-1402 # 8001a978 <tickslock>
    80002efa:	ffffe097          	auipc	ra,0xffffe
    80002efe:	dbc080e7          	jalr	-580(ra) # 80000cb6 <release>
      return -1;
    80002f02:	57fd                	li	a5,-1
    80002f04:	bff9                	j	80002ee2 <sys_sleep+0x8c>

0000000080002f06 <sys_kill>:

uint64
sys_kill(void)
{
    80002f06:	1101                	addi	sp,sp,-32
    80002f08:	ec06                	sd	ra,24(sp)
    80002f0a:	e822                	sd	s0,16(sp)
    80002f0c:	1000                	addi	s0,sp,32
  int pid;

  if(argint(0, &pid) < 0)
    80002f0e:	fec40593          	addi	a1,s0,-20
    80002f12:	4501                	li	a0,0
    80002f14:	00000097          	auipc	ra,0x0
    80002f18:	d80080e7          	jalr	-640(ra) # 80002c94 <argint>
    return -1;
    80002f1c:	57fd                	li	a5,-1
  if(argint(0, &pid) < 0)
    80002f1e:	00054963          	bltz	a0,80002f30 <sys_kill+0x2a>
  return kill(pid);
    80002f22:	fec42503          	lw	a0,-20(s0)
    80002f26:	fffff097          	auipc	ra,0xfffff
    80002f2a:	6ac080e7          	jalr	1708(ra) # 800025d2 <kill>
    80002f2e:	87aa                	mv	a5,a0
}
    80002f30:	853e                	mv	a0,a5
    80002f32:	60e2                	ld	ra,24(sp)
    80002f34:	6442                	ld	s0,16(sp)
    80002f36:	6105                	addi	sp,sp,32
    80002f38:	8082                	ret

0000000080002f3a <sys_uptime>:

// return how many clock tick interrupts have occurred
// since start.
uint64
sys_uptime(void)
{
    80002f3a:	1101                	addi	sp,sp,-32
    80002f3c:	ec06                	sd	ra,24(sp)
    80002f3e:	e822                	sd	s0,16(sp)
    80002f40:	e426                	sd	s1,8(sp)
    80002f42:	1000                	addi	s0,sp,32
  uint xticks;

  acquire(&tickslock);
    80002f44:	00018517          	auipc	a0,0x18
    80002f48:	a3450513          	addi	a0,a0,-1484 # 8001a978 <tickslock>
    80002f4c:	ffffe097          	auipc	ra,0xffffe
    80002f50:	cfa080e7          	jalr	-774(ra) # 80000c46 <acquire>
  xticks = ticks;
    80002f54:	0002d797          	auipc	a5,0x2d
    80002f58:	0ec78793          	addi	a5,a5,236 # 80030040 <ticks>
    80002f5c:	4384                	lw	s1,0(a5)
  release(&tickslock);
    80002f5e:	00018517          	auipc	a0,0x18
    80002f62:	a1a50513          	addi	a0,a0,-1510 # 8001a978 <tickslock>
    80002f66:	ffffe097          	auipc	ra,0xffffe
    80002f6a:	d50080e7          	jalr	-688(ra) # 80000cb6 <release>
  return xticks;
}
    80002f6e:	02049513          	slli	a0,s1,0x20
    80002f72:	9101                	srli	a0,a0,0x20
    80002f74:	60e2                	ld	ra,24(sp)
    80002f76:	6442                	ld	s0,16(sp)
    80002f78:	64a2                	ld	s1,8(sp)
    80002f7a:	6105                	addi	sp,sp,32
    80002f7c:	8082                	ret

0000000080002f7e <binit>:
  struct bucket bucket[NBUCKET];
} bcache;

void
binit(void)
{
    80002f7e:	7179                	addi	sp,sp,-48
    80002f80:	f406                	sd	ra,40(sp)
    80002f82:	f022                	sd	s0,32(sp)
    80002f84:	ec26                	sd	s1,24(sp)
    80002f86:	e84a                	sd	s2,16(sp)
    80002f88:	e44e                	sd	s3,8(sp)
    80002f8a:	1800                	addi	s0,sp,48
  struct buf *b;

  initlock(&bcache.lock, "bcache");
    80002f8c:	00005597          	auipc	a1,0x5
    80002f90:	32c58593          	addi	a1,a1,812 # 800082b8 <userret+0x228>
    80002f94:	00018517          	auipc	a0,0x18
    80002f98:	a0450513          	addi	a0,a0,-1532 # 8001a998 <bcache>
    80002f9c:	ffffe097          	auipc	ra,0xffffe
    80002fa0:	b5a080e7          	jalr	-1190(ra) # 80000af6 <initlock>

  for(int i = 0; i < NBUCKET; i++){
    80002fa4:	00020497          	auipc	s1,0x20
    80002fa8:	e4448493          	addi	s1,s1,-444 # 80022de8 <bcache+0x8450>
    80002fac:	00024997          	auipc	s3,0x24
    80002fb0:	92498993          	addi	s3,s3,-1756 # 800268d0 <sb>
    initlock(&bcache.bucket[i].lock, "bcache.bucket");
    80002fb4:	00005917          	auipc	s2,0x5
    80002fb8:	66c90913          	addi	s2,s2,1644 # 80008620 <userret+0x590>
    80002fbc:	85ca                	mv	a1,s2
    80002fbe:	8526                	mv	a0,s1
    80002fc0:	ffffe097          	auipc	ra,0xffffe
    80002fc4:	b36080e7          	jalr	-1226(ra) # 80000af6 <initlock>
    bcache.bucket[i].head.prev = &bcache.bucket[i].head;
    80002fc8:	02048793          	addi	a5,s1,32
    80002fcc:	f8bc                	sd	a5,112(s1)
    bcache.bucket[i].head.next = &bcache.bucket[i].head;
    80002fce:	fcbc                	sd	a5,120(s1)
  for(int i = 0; i < NBUCKET; i++){
    80002fd0:	48848493          	addi	s1,s1,1160
    80002fd4:	ff3494e3          	bne	s1,s3,80002fbc <binit+0x3e>
    80002fd8:	00018497          	auipc	s1,0x18
    80002fdc:	9f048493          	addi	s1,s1,-1552 # 8001a9c8 <bcache+0x30>
    80002fe0:	00018917          	auipc	s2,0x18
    80002fe4:	9b890913          	addi	s2,s2,-1608 # 8001a998 <bcache>
    80002fe8:	67a1                	lui	a5,0x8
    80002fea:	46078793          	addi	a5,a5,1120 # 8460 <_entry-0x7fff7ba0>
    80002fee:	993e                	add	s2,s2,a5
  }

  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
    initsleeplock(&b->lock, "buffer");
    80002ff0:	00005997          	auipc	s3,0x5
    80002ff4:	64098993          	addi	s3,s3,1600 # 80008630 <userret+0x5a0>
    80002ff8:	85ce                	mv	a1,s3
    80002ffa:	8526                	mv	a0,s1
    80002ffc:	00001097          	auipc	ra,0x1
    80003000:	710080e7          	jalr	1808(ra) # 8000470c <initsleeplock>
    b->refcnt = 0;
    80003004:	0204ac23          	sw	zero,56(s1)
    b->timestamp = 0;
    80003008:	0404a823          	sw	zero,80(s1)
  for(b = bcache.buf; b < bcache.buf+NBUF; b++){
    8000300c:	46848493          	addi	s1,s1,1128
    80003010:	ff2494e3          	bne	s1,s2,80002ff8 <binit+0x7a>
  }
}
    80003014:	70a2                	ld	ra,40(sp)
    80003016:	7402                	ld	s0,32(sp)
    80003018:	64e2                	ld	s1,24(sp)
    8000301a:	6942                	ld	s2,16(sp)
    8000301c:	69a2                	ld	s3,8(sp)
    8000301e:	6145                	addi	sp,sp,48
    80003020:	8082                	ret

0000000080003022 <bread>:
}

// Return a locked buf with the contents of the indicated block.
struct buf*
bread(uint dev, uint blockno)
{
    80003022:	715d                	addi	sp,sp,-80
    80003024:	e486                	sd	ra,72(sp)
    80003026:	e0a2                	sd	s0,64(sp)
    80003028:	fc26                	sd	s1,56(sp)
    8000302a:	f84a                	sd	s2,48(sp)
    8000302c:	f44e                	sd	s3,40(sp)
    8000302e:	f052                	sd	s4,32(sp)
    80003030:	ec56                	sd	s5,24(sp)
    80003032:	e85a                	sd	s6,16(sp)
    80003034:	e45e                	sd	s7,8(sp)
    80003036:	e062                	sd	s8,0(sp)
    80003038:	0880                	addi	s0,sp,80
    8000303a:	8baa                	mv	s7,a0
    8000303c:	8b2e                	mv	s6,a1
  int hash = blockno % NBUCKET;
    8000303e:	4a35                	li	s4,13
    80003040:	0345fa3b          	remuw	s4,a1,s4
  acquire(&bkt->lock);
    80003044:	48800913          	li	s2,1160
    80003048:	032a0933          	mul	s2,s4,s2
    8000304c:	6aa1                	lui	s5,0x8
    8000304e:	450a8993          	addi	s3,s5,1104 # 8450 <_entry-0x7fff7bb0>
    80003052:	99ca                	add	s3,s3,s2
    80003054:	00018c17          	auipc	s8,0x18
    80003058:	944c0c13          	addi	s8,s8,-1724 # 8001a998 <bcache>
    8000305c:	99e2                	add	s3,s3,s8
    8000305e:	854e                	mv	a0,s3
    80003060:	ffffe097          	auipc	ra,0xffffe
    80003064:	be6080e7          	jalr	-1050(ra) # 80000c46 <acquire>
  for(b = bkt->head.next; b != &bkt->head; b = b->next){
    80003068:	012c07b3          	add	a5,s8,s2
    8000306c:	97d6                	add	a5,a5,s5
    8000306e:	4c87b483          	ld	s1,1224(a5)
    80003072:	470a8a93          	addi	s5,s5,1136
    80003076:	9956                	add	s2,s2,s5
    80003078:	9962                	add	s2,s2,s8
    8000307a:	03249d63          	bne	s1,s2,800030b4 <bread+0x92>
  release(&bkt->lock);
    8000307e:	854e                	mv	a0,s3
    80003080:	ffffe097          	auipc	ra,0xffffe
    80003084:	c36080e7          	jalr	-970(ra) # 80000cb6 <release>
  acquire(&bcache.lock);
    80003088:	00018517          	auipc	a0,0x18
    8000308c:	91050513          	addi	a0,a0,-1776 # 8001a998 <bcache>
    80003090:	ffffe097          	auipc	ra,0xffffe
    80003094:	bb6080e7          	jalr	-1098(ra) # 80000c46 <acquire>
  for(int i = 0; i < NBUF; i++){
    80003098:	00018797          	auipc	a5,0x18
    8000309c:	92078793          	addi	a5,a5,-1760 # 8001a9b8 <bcache+0x20>
    800030a0:	00020597          	auipc	a1,0x20
    800030a4:	d4858593          	addi	a1,a1,-696 # 80022de8 <bcache+0x8450>
  struct buf *victim = 0;
    800030a8:	4481                	li	s1,0
  uint min_ts = ~0U;
    800030aa:	56fd                	li	a3,-1
    800030ac:	a82d                	j	800030e6 <bread+0xc4>
  for(b = bkt->head.next; b != &bkt->head; b = b->next){
    800030ae:	6ca4                	ld	s1,88(s1)
    800030b0:	fd2487e3          	beq	s1,s2,8000307e <bread+0x5c>
    if(b->dev == dev && b->blockno == blockno){
    800030b4:	449c                	lw	a5,8(s1)
    800030b6:	ff779ce3          	bne	a5,s7,800030ae <bread+0x8c>
    800030ba:	44dc                	lw	a5,12(s1)
    800030bc:	ff6799e3          	bne	a5,s6,800030ae <bread+0x8c>
      b->refcnt++;
    800030c0:	44bc                	lw	a5,72(s1)
    800030c2:	2785                	addiw	a5,a5,1
    800030c4:	c4bc                	sw	a5,72(s1)
      release(&bkt->lock);
    800030c6:	854e                	mv	a0,s3
    800030c8:	ffffe097          	auipc	ra,0xffffe
    800030cc:	bee080e7          	jalr	-1042(ra) # 80000cb6 <release>
      acquiresleep(&b->lock);
    800030d0:	01048513          	addi	a0,s1,16
    800030d4:	00001097          	auipc	ra,0x1
    800030d8:	672080e7          	jalr	1650(ra) # 80004746 <acquiresleep>
      return b;
    800030dc:	a0ed                	j	800031c6 <bread+0x1a4>
  for(int i = 0; i < NBUF; i++){
    800030de:	46878793          	addi	a5,a5,1128
    800030e2:	00b78a63          	beq	a5,a1,800030f6 <bread+0xd4>
    if(b->refcnt == 0 && b->timestamp < min_ts){
    800030e6:	47b8                	lw	a4,72(a5)
    800030e8:	fb7d                	bnez	a4,800030de <bread+0xbc>
    800030ea:	53b8                	lw	a4,96(a5)
    800030ec:	fed779e3          	bleu	a3,a4,800030de <bread+0xbc>
      min_ts = b->timestamp;
    800030f0:	86ba                	mv	a3,a4
      victim = b;
    800030f2:	84be                	mv	s1,a5
    800030f4:	b7ed                	j	800030de <bread+0xbc>
  if(!victim)
    800030f6:	c4fd                	beqz	s1,800031e4 <bread+0x1c2>
  if(victim->valid && old_hash != hash){
    800030f8:	409c                	lw	a5,0(s1)
    800030fa:	12078463          	beqz	a5,80003222 <bread+0x200>
  int old_hash = victim->blockno % NBUCKET;
    800030fe:	00c4aa83          	lw	s5,12(s1)
    80003102:	4535                	li	a0,13
    80003104:	02aafabb          	remuw	s5,s5,a0
  if(victim->valid && old_hash != hash){
    80003108:	095a0363          	beq	s4,s5,8000318e <bread+0x16c>
    if(old_hash < hash){
    8000310c:	0f4ad463          	ble	s4,s5,800031f4 <bread+0x1d2>
      acquire(&old_bkt->lock);
    80003110:	48800793          	li	a5,1160
    80003114:	02fa87b3          	mul	a5,s5,a5
    80003118:	6521                	lui	a0,0x8
    8000311a:	45050513          	addi	a0,a0,1104 # 8450 <_entry-0x7fff7bb0>
    8000311e:	97aa                	add	a5,a5,a0
    80003120:	00018517          	auipc	a0,0x18
    80003124:	87850513          	addi	a0,a0,-1928 # 8001a998 <bcache>
    80003128:	953e                	add	a0,a0,a5
    8000312a:	ffffe097          	auipc	ra,0xffffe
    8000312e:	b1c080e7          	jalr	-1252(ra) # 80000c46 <acquire>
      acquire(&bkt->lock);
    80003132:	854e                	mv	a0,s3
    80003134:	ffffe097          	auipc	ra,0xffffe
    80003138:	b12080e7          	jalr	-1262(ra) # 80000c46 <acquire>
    victim->prev->next = victim->next;
    8000313c:	68b8                	ld	a4,80(s1)
    8000313e:	6cbc                	ld	a5,88(s1)
    80003140:	ef3c                	sd	a5,88(a4)
    victim->next->prev = victim->prev;
    80003142:	68b8                	ld	a4,80(s1)
    80003144:	ebb8                	sd	a4,80(a5)
    victim->next = bkt->head.next;
    80003146:	00018517          	auipc	a0,0x18
    8000314a:	85250513          	addi	a0,a0,-1966 # 8001a998 <bcache>
    8000314e:	48800713          	li	a4,1160
    80003152:	02ea0a33          	mul	s4,s4,a4
    80003156:	9a2a                	add	s4,s4,a0
    80003158:	67a1                	lui	a5,0x8
    8000315a:	9a3e                	add	s4,s4,a5
    8000315c:	4c8a3683          	ld	a3,1224(s4)
    80003160:	ecb4                	sd	a3,88(s1)
    victim->prev = &bkt->head;
    80003162:	0524b823          	sd	s2,80(s1)
    bkt->head.next->prev = victim;
    80003166:	4c8a3683          	ld	a3,1224(s4)
    8000316a:	eaa4                	sd	s1,80(a3)
    bkt->head.next = victim;
    8000316c:	4c9a3423          	sd	s1,1224(s4)
    release(&old_bkt->lock);
    80003170:	02ea8ab3          	mul	s5,s5,a4
    80003174:	45078793          	addi	a5,a5,1104 # 8450 <_entry-0x7fff7bb0>
    80003178:	9abe                	add	s5,s5,a5
    8000317a:	9556                	add	a0,a0,s5
    8000317c:	ffffe097          	auipc	ra,0xffffe
    80003180:	b3a080e7          	jalr	-1222(ra) # 80000cb6 <release>
    release(&bkt->lock);
    80003184:	854e                	mv	a0,s3
    80003186:	ffffe097          	auipc	ra,0xffffe
    8000318a:	b30080e7          	jalr	-1232(ra) # 80000cb6 <release>
  victim->dev = dev;
    8000318e:	0174a423          	sw	s7,8(s1)
  victim->blockno = blockno;
    80003192:	0164a623          	sw	s6,12(s1)
  victim->valid = 0;
    80003196:	0004a023          	sw	zero,0(s1)
  victim->refcnt = 1;
    8000319a:	4785                	li	a5,1
    8000319c:	c4bc                	sw	a5,72(s1)
  victim->timestamp = ticks;
    8000319e:	0002d797          	auipc	a5,0x2d
    800031a2:	ea278793          	addi	a5,a5,-350 # 80030040 <ticks>
    800031a6:	439c                	lw	a5,0(a5)
    800031a8:	d0bc                	sw	a5,96(s1)
  release(&bcache.lock);
    800031aa:	00017517          	auipc	a0,0x17
    800031ae:	7ee50513          	addi	a0,a0,2030 # 8001a998 <bcache>
    800031b2:	ffffe097          	auipc	ra,0xffffe
    800031b6:	b04080e7          	jalr	-1276(ra) # 80000cb6 <release>
  acquiresleep(&victim->lock);
    800031ba:	01048513          	addi	a0,s1,16
    800031be:	00001097          	auipc	ra,0x1
    800031c2:	588080e7          	jalr	1416(ra) # 80004746 <acquiresleep>
  struct buf *b;

  b = bget(dev, blockno);
  if(!b->valid) {
    800031c6:	409c                	lw	a5,0(s1)
    800031c8:	cfc9                	beqz	a5,80003262 <bread+0x240>
    virtio_disk_rw(b->dev, b, 0);
    b->valid = 1;
  }
  return b;
}
    800031ca:	8526                	mv	a0,s1
    800031cc:	60a6                	ld	ra,72(sp)
    800031ce:	6406                	ld	s0,64(sp)
    800031d0:	74e2                	ld	s1,56(sp)
    800031d2:	7942                	ld	s2,48(sp)
    800031d4:	79a2                	ld	s3,40(sp)
    800031d6:	7a02                	ld	s4,32(sp)
    800031d8:	6ae2                	ld	s5,24(sp)
    800031da:	6b42                	ld	s6,16(sp)
    800031dc:	6ba2                	ld	s7,8(sp)
    800031de:	6c02                	ld	s8,0(sp)
    800031e0:	6161                	addi	sp,sp,80
    800031e2:	8082                	ret
    panic("bget: no buffers");
    800031e4:	00005517          	auipc	a0,0x5
    800031e8:	45450513          	addi	a0,a0,1108 # 80008638 <userret+0x5a8>
    800031ec:	ffffd097          	auipc	ra,0xffffd
    800031f0:	392080e7          	jalr	914(ra) # 8000057e <panic>
      acquire(&bkt->lock);
    800031f4:	854e                	mv	a0,s3
    800031f6:	ffffe097          	auipc	ra,0xffffe
    800031fa:	a50080e7          	jalr	-1456(ra) # 80000c46 <acquire>
      acquire(&old_bkt->lock);
    800031fe:	48800793          	li	a5,1160
    80003202:	02fa87b3          	mul	a5,s5,a5
    80003206:	6521                	lui	a0,0x8
    80003208:	45050513          	addi	a0,a0,1104 # 8450 <_entry-0x7fff7bb0>
    8000320c:	97aa                	add	a5,a5,a0
    8000320e:	00017517          	auipc	a0,0x17
    80003212:	78a50513          	addi	a0,a0,1930 # 8001a998 <bcache>
    80003216:	953e                	add	a0,a0,a5
    80003218:	ffffe097          	auipc	ra,0xffffe
    8000321c:	a2e080e7          	jalr	-1490(ra) # 80000c46 <acquire>
    80003220:	bf31                	j	8000313c <bread+0x11a>
    acquire(&bkt->lock);
    80003222:	854e                	mv	a0,s3
    80003224:	ffffe097          	auipc	ra,0xffffe
    80003228:	a22080e7          	jalr	-1502(ra) # 80000c46 <acquire>
    victim->next = bkt->head.next;
    8000322c:	48800793          	li	a5,1160
    80003230:	02fa0a33          	mul	s4,s4,a5
    80003234:	00017797          	auipc	a5,0x17
    80003238:	76478793          	addi	a5,a5,1892 # 8001a998 <bcache>
    8000323c:	97d2                	add	a5,a5,s4
    8000323e:	6a21                	lui	s4,0x8
    80003240:	9a3e                	add	s4,s4,a5
    80003242:	4c8a3783          	ld	a5,1224(s4) # 84c8 <_entry-0x7fff7b38>
    80003246:	ecbc                	sd	a5,88(s1)
    victim->prev = &bkt->head;
    80003248:	0524b823          	sd	s2,80(s1)
    bkt->head.next->prev = victim;
    8000324c:	4c8a3783          	ld	a5,1224(s4)
    80003250:	eba4                	sd	s1,80(a5)
    bkt->head.next = victim;
    80003252:	4c9a3423          	sd	s1,1224(s4)
    release(&bkt->lock);
    80003256:	854e                	mv	a0,s3
    80003258:	ffffe097          	auipc	ra,0xffffe
    8000325c:	a5e080e7          	jalr	-1442(ra) # 80000cb6 <release>
    80003260:	b73d                	j	8000318e <bread+0x16c>
    virtio_disk_rw(b->dev, b, 0);
    80003262:	4601                	li	a2,0
    80003264:	85a6                	mv	a1,s1
    80003266:	4488                	lw	a0,8(s1)
    80003268:	00003097          	auipc	ra,0x3
    8000326c:	172080e7          	jalr	370(ra) # 800063da <virtio_disk_rw>
    b->valid = 1;
    80003270:	4785                	li	a5,1
    80003272:	c09c                	sw	a5,0(s1)
  return b;
    80003274:	bf99                	j	800031ca <bread+0x1a8>

0000000080003276 <bwrite>:

// Write b's contents to disk.  Must be locked.
void
bwrite(struct buf *b)
{
    80003276:	1101                	addi	sp,sp,-32
    80003278:	ec06                	sd	ra,24(sp)
    8000327a:	e822                	sd	s0,16(sp)
    8000327c:	e426                	sd	s1,8(sp)
    8000327e:	1000                	addi	s0,sp,32
    80003280:	84aa                	mv	s1,a0
  if(!holdingsleep(&b->lock))
    80003282:	0541                	addi	a0,a0,16
    80003284:	00001097          	auipc	ra,0x1
    80003288:	55c080e7          	jalr	1372(ra) # 800047e0 <holdingsleep>
    8000328c:	cd09                	beqz	a0,800032a6 <bwrite+0x30>
    panic("bwrite");
  virtio_disk_rw(b->dev, b, 1);
    8000328e:	4605                	li	a2,1
    80003290:	85a6                	mv	a1,s1
    80003292:	4488                	lw	a0,8(s1)
    80003294:	00003097          	auipc	ra,0x3
    80003298:	146080e7          	jalr	326(ra) # 800063da <virtio_disk_rw>
}
    8000329c:	60e2                	ld	ra,24(sp)
    8000329e:	6442                	ld	s0,16(sp)
    800032a0:	64a2                	ld	s1,8(sp)
    800032a2:	6105                	addi	sp,sp,32
    800032a4:	8082                	ret
    panic("bwrite");
    800032a6:	00005517          	auipc	a0,0x5
    800032aa:	3aa50513          	addi	a0,a0,938 # 80008650 <userret+0x5c0>
    800032ae:	ffffd097          	auipc	ra,0xffffd
    800032b2:	2d0080e7          	jalr	720(ra) # 8000057e <panic>

00000000800032b6 <brelse>:

// Release a locked buffer.
// Move to the head of the MRU list.
void
brelse(struct buf *b)
{
    800032b6:	1101                	addi	sp,sp,-32
    800032b8:	ec06                	sd	ra,24(sp)
    800032ba:	e822                	sd	s0,16(sp)
    800032bc:	e426                	sd	s1,8(sp)
    800032be:	e04a                	sd	s2,0(sp)
    800032c0:	1000                	addi	s0,sp,32
    800032c2:	84aa                	mv	s1,a0
  if(!holdingsleep(&b->lock))
    800032c4:	01050913          	addi	s2,a0,16
    800032c8:	854a                	mv	a0,s2
    800032ca:	00001097          	auipc	ra,0x1
    800032ce:	516080e7          	jalr	1302(ra) # 800047e0 <holdingsleep>
    800032d2:	c50d                	beqz	a0,800032fc <brelse+0x46>
    panic("brelse");

  releasesleep(&b->lock);
    800032d4:	854a                	mv	a0,s2
    800032d6:	00001097          	auipc	ra,0x1
    800032da:	4c6080e7          	jalr	1222(ra) # 8000479c <releasesleep>

  b->timestamp = ticks;
    800032de:	0002d797          	auipc	a5,0x2d
    800032e2:	d6278793          	addi	a5,a5,-670 # 80030040 <ticks>
    800032e6:	439c                	lw	a5,0(a5)
    800032e8:	d0bc                	sw	a5,96(s1)
  b->refcnt--;
    800032ea:	44bc                	lw	a5,72(s1)
    800032ec:	37fd                	addiw	a5,a5,-1
    800032ee:	c4bc                	sw	a5,72(s1)
}
    800032f0:	60e2                	ld	ra,24(sp)
    800032f2:	6442                	ld	s0,16(sp)
    800032f4:	64a2                	ld	s1,8(sp)
    800032f6:	6902                	ld	s2,0(sp)
    800032f8:	6105                	addi	sp,sp,32
    800032fa:	8082                	ret
    panic("brelse");
    800032fc:	00005517          	auipc	a0,0x5
    80003300:	35c50513          	addi	a0,a0,860 # 80008658 <userret+0x5c8>
    80003304:	ffffd097          	auipc	ra,0xffffd
    80003308:	27a080e7          	jalr	634(ra) # 8000057e <panic>

000000008000330c <bpin>:

void
bpin(struct buf *b) {
    8000330c:	1101                	addi	sp,sp,-32
    8000330e:	ec06                	sd	ra,24(sp)
    80003310:	e822                	sd	s0,16(sp)
    80003312:	e426                	sd	s1,8(sp)
    80003314:	1000                	addi	s0,sp,32
    80003316:	84aa                	mv	s1,a0
  acquire(&bcache.lock);
    80003318:	00017517          	auipc	a0,0x17
    8000331c:	68050513          	addi	a0,a0,1664 # 8001a998 <bcache>
    80003320:	ffffe097          	auipc	ra,0xffffe
    80003324:	926080e7          	jalr	-1754(ra) # 80000c46 <acquire>
  b->refcnt++;
    80003328:	44bc                	lw	a5,72(s1)
    8000332a:	2785                	addiw	a5,a5,1
    8000332c:	c4bc                	sw	a5,72(s1)
  release(&bcache.lock);
    8000332e:	00017517          	auipc	a0,0x17
    80003332:	66a50513          	addi	a0,a0,1642 # 8001a998 <bcache>
    80003336:	ffffe097          	auipc	ra,0xffffe
    8000333a:	980080e7          	jalr	-1664(ra) # 80000cb6 <release>
}
    8000333e:	60e2                	ld	ra,24(sp)
    80003340:	6442                	ld	s0,16(sp)
    80003342:	64a2                	ld	s1,8(sp)
    80003344:	6105                	addi	sp,sp,32
    80003346:	8082                	ret

0000000080003348 <bunpin>:

void
bunpin(struct buf *b) {
    80003348:	1101                	addi	sp,sp,-32
    8000334a:	ec06                	sd	ra,24(sp)
    8000334c:	e822                	sd	s0,16(sp)
    8000334e:	e426                	sd	s1,8(sp)
    80003350:	1000                	addi	s0,sp,32
    80003352:	84aa                	mv	s1,a0
  acquire(&bcache.lock);
    80003354:	00017517          	auipc	a0,0x17
    80003358:	64450513          	addi	a0,a0,1604 # 8001a998 <bcache>
    8000335c:	ffffe097          	auipc	ra,0xffffe
    80003360:	8ea080e7          	jalr	-1814(ra) # 80000c46 <acquire>
  b->refcnt--;
    80003364:	44bc                	lw	a5,72(s1)
    80003366:	37fd                	addiw	a5,a5,-1
    80003368:	c4bc                	sw	a5,72(s1)
  release(&bcache.lock);
    8000336a:	00017517          	auipc	a0,0x17
    8000336e:	62e50513          	addi	a0,a0,1582 # 8001a998 <bcache>
    80003372:	ffffe097          	auipc	ra,0xffffe
    80003376:	944080e7          	jalr	-1724(ra) # 80000cb6 <release>
}
    8000337a:	60e2                	ld	ra,24(sp)
    8000337c:	6442                	ld	s0,16(sp)
    8000337e:	64a2                	ld	s1,8(sp)
    80003380:	6105                	addi	sp,sp,32
    80003382:	8082                	ret

0000000080003384 <bfree>:
}

// Free a disk block.
static void
bfree(int dev, uint b)
{
    80003384:	1101                	addi	sp,sp,-32
    80003386:	ec06                	sd	ra,24(sp)
    80003388:	e822                	sd	s0,16(sp)
    8000338a:	e426                	sd	s1,8(sp)
    8000338c:	e04a                	sd	s2,0(sp)
    8000338e:	1000                	addi	s0,sp,32
    80003390:	84ae                	mv	s1,a1
  struct buf *bp;
  int bi, m;

  bp = bread(dev, BBLOCK(b, sb));
    80003392:	00d5d59b          	srliw	a1,a1,0xd
    80003396:	00023797          	auipc	a5,0x23
    8000339a:	53a78793          	addi	a5,a5,1338 # 800268d0 <sb>
    8000339e:	4fdc                	lw	a5,28(a5)
    800033a0:	9dbd                	addw	a1,a1,a5
    800033a2:	00000097          	auipc	ra,0x0
    800033a6:	c80080e7          	jalr	-896(ra) # 80003022 <bread>
  bi = b % BPB;
    800033aa:	2481                	sext.w	s1,s1
  m = 1 << (bi % 8);
    800033ac:	0074f793          	andi	a5,s1,7
    800033b0:	4705                	li	a4,1
    800033b2:	00f7173b          	sllw	a4,a4,a5
  bi = b % BPB;
    800033b6:	6789                	lui	a5,0x2
    800033b8:	17fd                	addi	a5,a5,-1
    800033ba:	8cfd                	and	s1,s1,a5
  if((bp->data[bi/8] & m) == 0)
    800033bc:	41f4d79b          	sraiw	a5,s1,0x1f
    800033c0:	01d7d79b          	srliw	a5,a5,0x1d
    800033c4:	9fa5                	addw	a5,a5,s1
    800033c6:	4037d79b          	sraiw	a5,a5,0x3
    800033ca:	00f506b3          	add	a3,a0,a5
    800033ce:	0646c683          	lbu	a3,100(a3)
    800033d2:	00d77633          	and	a2,a4,a3
    800033d6:	c61d                	beqz	a2,80003404 <bfree+0x80>
    800033d8:	892a                	mv	s2,a0
    panic("freeing free block");
  bp->data[bi/8] &= ~m;
    800033da:	97aa                	add	a5,a5,a0
    800033dc:	fff74713          	not	a4,a4
    800033e0:	8f75                	and	a4,a4,a3
    800033e2:	06e78223          	sb	a4,100(a5) # 2064 <_entry-0x7fffdf9c>
  log_write(bp);
    800033e6:	00001097          	auipc	ra,0x1
    800033ea:	1c8080e7          	jalr	456(ra) # 800045ae <log_write>
  brelse(bp);
    800033ee:	854a                	mv	a0,s2
    800033f0:	00000097          	auipc	ra,0x0
    800033f4:	ec6080e7          	jalr	-314(ra) # 800032b6 <brelse>
}
    800033f8:	60e2                	ld	ra,24(sp)
    800033fa:	6442                	ld	s0,16(sp)
    800033fc:	64a2                	ld	s1,8(sp)
    800033fe:	6902                	ld	s2,0(sp)
    80003400:	6105                	addi	sp,sp,32
    80003402:	8082                	ret
    panic("freeing free block");
    80003404:	00005517          	auipc	a0,0x5
    80003408:	25c50513          	addi	a0,a0,604 # 80008660 <userret+0x5d0>
    8000340c:	ffffd097          	auipc	ra,0xffffd
    80003410:	172080e7          	jalr	370(ra) # 8000057e <panic>

0000000080003414 <balloc>:
{
    80003414:	711d                	addi	sp,sp,-96
    80003416:	ec86                	sd	ra,88(sp)
    80003418:	e8a2                	sd	s0,80(sp)
    8000341a:	e4a6                	sd	s1,72(sp)
    8000341c:	e0ca                	sd	s2,64(sp)
    8000341e:	fc4e                	sd	s3,56(sp)
    80003420:	f852                	sd	s4,48(sp)
    80003422:	f456                	sd	s5,40(sp)
    80003424:	f05a                	sd	s6,32(sp)
    80003426:	ec5e                	sd	s7,24(sp)
    80003428:	e862                	sd	s8,16(sp)
    8000342a:	e466                	sd	s9,8(sp)
    8000342c:	1080                	addi	s0,sp,96
  for(b = 0; b < sb.size; b += BPB){
    8000342e:	00023797          	auipc	a5,0x23
    80003432:	4a278793          	addi	a5,a5,1186 # 800268d0 <sb>
    80003436:	43dc                	lw	a5,4(a5)
    80003438:	10078e63          	beqz	a5,80003554 <balloc+0x140>
    8000343c:	8baa                	mv	s7,a0
    8000343e:	4a81                	li	s5,0
    bp = bread(dev, BBLOCK(b, sb));
    80003440:	00023b17          	auipc	s6,0x23
    80003444:	490b0b13          	addi	s6,s6,1168 # 800268d0 <sb>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80003448:	4c05                	li	s8,1
      m = 1 << (bi % 8);
    8000344a:	4985                	li	s3,1
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    8000344c:	6a09                	lui	s4,0x2
  for(b = 0; b < sb.size; b += BPB){
    8000344e:	6c89                	lui	s9,0x2
    80003450:	a079                	j	800034de <balloc+0xca>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80003452:	8942                	mv	s2,a6
      m = 1 << (bi % 8);
    80003454:	4705                	li	a4,1
      if((bp->data[bi/8] & m) == 0){  // Is block free?
    80003456:	4681                	li	a3,0
        bp->data[bi/8] |= m;  // Mark block in use.
    80003458:	96a6                	add	a3,a3,s1
    8000345a:	8f51                	or	a4,a4,a2
    8000345c:	06e68223          	sb	a4,100(a3)
        log_write(bp);
    80003460:	8526                	mv	a0,s1
    80003462:	00001097          	auipc	ra,0x1
    80003466:	14c080e7          	jalr	332(ra) # 800045ae <log_write>
        brelse(bp);
    8000346a:	8526                	mv	a0,s1
    8000346c:	00000097          	auipc	ra,0x0
    80003470:	e4a080e7          	jalr	-438(ra) # 800032b6 <brelse>
  bp = bread(dev, bno);
    80003474:	85ca                	mv	a1,s2
    80003476:	855e                	mv	a0,s7
    80003478:	00000097          	auipc	ra,0x0
    8000347c:	baa080e7          	jalr	-1110(ra) # 80003022 <bread>
    80003480:	84aa                	mv	s1,a0
  memset(bp->data, 0, BSIZE);
    80003482:	40000613          	li	a2,1024
    80003486:	4581                	li	a1,0
    80003488:	06450513          	addi	a0,a0,100
    8000348c:	ffffe097          	auipc	ra,0xffffe
    80003490:	a50080e7          	jalr	-1456(ra) # 80000edc <memset>
  log_write(bp);
    80003494:	8526                	mv	a0,s1
    80003496:	00001097          	auipc	ra,0x1
    8000349a:	118080e7          	jalr	280(ra) # 800045ae <log_write>
  brelse(bp);
    8000349e:	8526                	mv	a0,s1
    800034a0:	00000097          	auipc	ra,0x0
    800034a4:	e16080e7          	jalr	-490(ra) # 800032b6 <brelse>
}
    800034a8:	854a                	mv	a0,s2
    800034aa:	60e6                	ld	ra,88(sp)
    800034ac:	6446                	ld	s0,80(sp)
    800034ae:	64a6                	ld	s1,72(sp)
    800034b0:	6906                	ld	s2,64(sp)
    800034b2:	79e2                	ld	s3,56(sp)
    800034b4:	7a42                	ld	s4,48(sp)
    800034b6:	7aa2                	ld	s5,40(sp)
    800034b8:	7b02                	ld	s6,32(sp)
    800034ba:	6be2                	ld	s7,24(sp)
    800034bc:	6c42                	ld	s8,16(sp)
    800034be:	6ca2                	ld	s9,8(sp)
    800034c0:	6125                	addi	sp,sp,96
    800034c2:	8082                	ret
    brelse(bp);
    800034c4:	8526                	mv	a0,s1
    800034c6:	00000097          	auipc	ra,0x0
    800034ca:	df0080e7          	jalr	-528(ra) # 800032b6 <brelse>
  for(b = 0; b < sb.size; b += BPB){
    800034ce:	015c87bb          	addw	a5,s9,s5
    800034d2:	00078a9b          	sext.w	s5,a5
    800034d6:	004b2703          	lw	a4,4(s6)
    800034da:	06eafd63          	bleu	a4,s5,80003554 <balloc+0x140>
    bp = bread(dev, BBLOCK(b, sb));
    800034de:	41fad79b          	sraiw	a5,s5,0x1f
    800034e2:	0137d79b          	srliw	a5,a5,0x13
    800034e6:	015787bb          	addw	a5,a5,s5
    800034ea:	40d7d79b          	sraiw	a5,a5,0xd
    800034ee:	01cb2583          	lw	a1,28(s6)
    800034f2:	9dbd                	addw	a1,a1,a5
    800034f4:	855e                	mv	a0,s7
    800034f6:	00000097          	auipc	ra,0x0
    800034fa:	b2c080e7          	jalr	-1236(ra) # 80003022 <bread>
    800034fe:	84aa                	mv	s1,a0
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    80003500:	000a881b          	sext.w	a6,s5
    80003504:	004b2503          	lw	a0,4(s6)
    80003508:	faa87ee3          	bleu	a0,a6,800034c4 <balloc+0xb0>
      if((bp->data[bi/8] & m) == 0){  // Is block free?
    8000350c:	0644c603          	lbu	a2,100(s1)
    80003510:	00167793          	andi	a5,a2,1
    80003514:	df9d                	beqz	a5,80003452 <balloc+0x3e>
    80003516:	4105053b          	subw	a0,a0,a6
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    8000351a:	87e2                	mv	a5,s8
    8000351c:	0107893b          	addw	s2,a5,a6
    80003520:	faa782e3          	beq	a5,a0,800034c4 <balloc+0xb0>
      m = 1 << (bi % 8);
    80003524:	41f7d71b          	sraiw	a4,a5,0x1f
    80003528:	01d7561b          	srliw	a2,a4,0x1d
    8000352c:	00f606bb          	addw	a3,a2,a5
    80003530:	0076f713          	andi	a4,a3,7
    80003534:	9f11                	subw	a4,a4,a2
    80003536:	00e9973b          	sllw	a4,s3,a4
      if((bp->data[bi/8] & m) == 0){  // Is block free?
    8000353a:	4036d69b          	sraiw	a3,a3,0x3
    8000353e:	00d48633          	add	a2,s1,a3
    80003542:	06464603          	lbu	a2,100(a2)
    80003546:	00c775b3          	and	a1,a4,a2
    8000354a:	d599                	beqz	a1,80003458 <balloc+0x44>
    for(bi = 0; bi < BPB && b + bi < sb.size; bi++){
    8000354c:	2785                	addiw	a5,a5,1
    8000354e:	fd4797e3          	bne	a5,s4,8000351c <balloc+0x108>
    80003552:	bf8d                	j	800034c4 <balloc+0xb0>
  panic("balloc: out of blocks");
    80003554:	00005517          	auipc	a0,0x5
    80003558:	12450513          	addi	a0,a0,292 # 80008678 <userret+0x5e8>
    8000355c:	ffffd097          	auipc	ra,0xffffd
    80003560:	022080e7          	jalr	34(ra) # 8000057e <panic>

0000000080003564 <bmap>:

// Return the disk block address of the nth block in inode ip.
// If there is no such block, bmap allocates one.
static uint
bmap(struct inode *ip, uint bn)
{
    80003564:	7179                	addi	sp,sp,-48
    80003566:	f406                	sd	ra,40(sp)
    80003568:	f022                	sd	s0,32(sp)
    8000356a:	ec26                	sd	s1,24(sp)
    8000356c:	e84a                	sd	s2,16(sp)
    8000356e:	e44e                	sd	s3,8(sp)
    80003570:	e052                	sd	s4,0(sp)
    80003572:	1800                	addi	s0,sp,48
    80003574:	89aa                	mv	s3,a0
  uint addr, *a;
  struct buf *bp;

  if(bn < NDIRECT){
    80003576:	47ad                	li	a5,11
    80003578:	04b7fe63          	bleu	a1,a5,800035d4 <bmap+0x70>
    if((addr = ip->addrs[bn]) == 0)
      ip->addrs[bn] = addr = balloc(ip->dev);
    return addr;
  }
  bn -= NDIRECT;
    8000357c:	ff45849b          	addiw	s1,a1,-12
    80003580:	0004871b          	sext.w	a4,s1

  if(bn < NINDIRECT){
    80003584:	0ff00793          	li	a5,255
    80003588:	0ae7e363          	bltu	a5,a4,8000362e <bmap+0xca>
    // Load indirect block, allocating if necessary.
    if((addr = ip->addrs[NDIRECT]) == 0)
    8000358c:	08852583          	lw	a1,136(a0)
    80003590:	c5ad                	beqz	a1,800035fa <bmap+0x96>
      ip->addrs[NDIRECT] = addr = balloc(ip->dev);
    bp = bread(ip->dev, addr);
    80003592:	0009a503          	lw	a0,0(s3)
    80003596:	00000097          	auipc	ra,0x0
    8000359a:	a8c080e7          	jalr	-1396(ra) # 80003022 <bread>
    8000359e:	8a2a                	mv	s4,a0
    a = (uint*)bp->data;
    800035a0:	06450793          	addi	a5,a0,100
    if((addr = a[bn]) == 0){
    800035a4:	02049593          	slli	a1,s1,0x20
    800035a8:	9181                	srli	a1,a1,0x20
    800035aa:	058a                	slli	a1,a1,0x2
    800035ac:	00b784b3          	add	s1,a5,a1
    800035b0:	0004a903          	lw	s2,0(s1)
    800035b4:	04090d63          	beqz	s2,8000360e <bmap+0xaa>
      a[bn] = addr = balloc(ip->dev);
      log_write(bp);
    }
    brelse(bp);
    800035b8:	8552                	mv	a0,s4
    800035ba:	00000097          	auipc	ra,0x0
    800035be:	cfc080e7          	jalr	-772(ra) # 800032b6 <brelse>
    return addr;
  }

  panic("bmap: out of range");
}
    800035c2:	854a                	mv	a0,s2
    800035c4:	70a2                	ld	ra,40(sp)
    800035c6:	7402                	ld	s0,32(sp)
    800035c8:	64e2                	ld	s1,24(sp)
    800035ca:	6942                	ld	s2,16(sp)
    800035cc:	69a2                	ld	s3,8(sp)
    800035ce:	6a02                	ld	s4,0(sp)
    800035d0:	6145                	addi	sp,sp,48
    800035d2:	8082                	ret
    if((addr = ip->addrs[bn]) == 0)
    800035d4:	02059493          	slli	s1,a1,0x20
    800035d8:	9081                	srli	s1,s1,0x20
    800035da:	048a                	slli	s1,s1,0x2
    800035dc:	94aa                	add	s1,s1,a0
    800035de:	0584a903          	lw	s2,88(s1)
    800035e2:	fe0910e3          	bnez	s2,800035c2 <bmap+0x5e>
      ip->addrs[bn] = addr = balloc(ip->dev);
    800035e6:	4108                	lw	a0,0(a0)
    800035e8:	00000097          	auipc	ra,0x0
    800035ec:	e2c080e7          	jalr	-468(ra) # 80003414 <balloc>
    800035f0:	0005091b          	sext.w	s2,a0
    800035f4:	0524ac23          	sw	s2,88(s1)
    800035f8:	b7e9                	j	800035c2 <bmap+0x5e>
      ip->addrs[NDIRECT] = addr = balloc(ip->dev);
    800035fa:	4108                	lw	a0,0(a0)
    800035fc:	00000097          	auipc	ra,0x0
    80003600:	e18080e7          	jalr	-488(ra) # 80003414 <balloc>
    80003604:	0005059b          	sext.w	a1,a0
    80003608:	08b9a423          	sw	a1,136(s3)
    8000360c:	b759                	j	80003592 <bmap+0x2e>
      a[bn] = addr = balloc(ip->dev);
    8000360e:	0009a503          	lw	a0,0(s3)
    80003612:	00000097          	auipc	ra,0x0
    80003616:	e02080e7          	jalr	-510(ra) # 80003414 <balloc>
    8000361a:	0005091b          	sext.w	s2,a0
    8000361e:	0124a023          	sw	s2,0(s1)
      log_write(bp);
    80003622:	8552                	mv	a0,s4
    80003624:	00001097          	auipc	ra,0x1
    80003628:	f8a080e7          	jalr	-118(ra) # 800045ae <log_write>
    8000362c:	b771                	j	800035b8 <bmap+0x54>
  panic("bmap: out of range");
    8000362e:	00005517          	auipc	a0,0x5
    80003632:	06250513          	addi	a0,a0,98 # 80008690 <userret+0x600>
    80003636:	ffffd097          	auipc	ra,0xffffd
    8000363a:	f48080e7          	jalr	-184(ra) # 8000057e <panic>

000000008000363e <iget>:
{
    8000363e:	7179                	addi	sp,sp,-48
    80003640:	f406                	sd	ra,40(sp)
    80003642:	f022                	sd	s0,32(sp)
    80003644:	ec26                	sd	s1,24(sp)
    80003646:	e84a                	sd	s2,16(sp)
    80003648:	e44e                	sd	s3,8(sp)
    8000364a:	e052                	sd	s4,0(sp)
    8000364c:	1800                	addi	s0,sp,48
    8000364e:	89aa                	mv	s3,a0
    80003650:	8a2e                	mv	s4,a1
  acquire(&icache.lock);
    80003652:	00023517          	auipc	a0,0x23
    80003656:	29e50513          	addi	a0,a0,670 # 800268f0 <icache>
    8000365a:	ffffd097          	auipc	ra,0xffffd
    8000365e:	5ec080e7          	jalr	1516(ra) # 80000c46 <acquire>
  empty = 0;
    80003662:	4901                	li	s2,0
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
    80003664:	00023497          	auipc	s1,0x23
    80003668:	2ac48493          	addi	s1,s1,684 # 80026910 <icache+0x20>
    8000366c:	00025697          	auipc	a3,0x25
    80003670:	ec468693          	addi	a3,a3,-316 # 80028530 <log>
    80003674:	a039                	j	80003682 <iget+0x44>
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
    80003676:	02090b63          	beqz	s2,800036ac <iget+0x6e>
  for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){
    8000367a:	09048493          	addi	s1,s1,144
    8000367e:	02d48a63          	beq	s1,a3,800036b2 <iget+0x74>
    if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){
    80003682:	449c                	lw	a5,8(s1)
    80003684:	fef059e3          	blez	a5,80003676 <iget+0x38>
    80003688:	4098                	lw	a4,0(s1)
    8000368a:	ff3716e3          	bne	a4,s3,80003676 <iget+0x38>
    8000368e:	40d8                	lw	a4,4(s1)
    80003690:	ff4713e3          	bne	a4,s4,80003676 <iget+0x38>
      ip->ref++;
    80003694:	2785                	addiw	a5,a5,1
    80003696:	c49c                	sw	a5,8(s1)
      release(&icache.lock);
    80003698:	00023517          	auipc	a0,0x23
    8000369c:	25850513          	addi	a0,a0,600 # 800268f0 <icache>
    800036a0:	ffffd097          	auipc	ra,0xffffd
    800036a4:	616080e7          	jalr	1558(ra) # 80000cb6 <release>
      return ip;
    800036a8:	8926                	mv	s2,s1
    800036aa:	a03d                	j	800036d8 <iget+0x9a>
    if(empty == 0 && ip->ref == 0)    // Remember empty slot.
    800036ac:	f7f9                	bnez	a5,8000367a <iget+0x3c>
    800036ae:	8926                	mv	s2,s1
    800036b0:	b7e9                	j	8000367a <iget+0x3c>
  if(empty == 0)
    800036b2:	02090c63          	beqz	s2,800036ea <iget+0xac>
  ip->dev = dev;
    800036b6:	01392023          	sw	s3,0(s2)
  ip->inum = inum;
    800036ba:	01492223          	sw	s4,4(s2)
  ip->ref = 1;
    800036be:	4785                	li	a5,1
    800036c0:	00f92423          	sw	a5,8(s2)
  ip->valid = 0;
    800036c4:	04092423          	sw	zero,72(s2)
  release(&icache.lock);
    800036c8:	00023517          	auipc	a0,0x23
    800036cc:	22850513          	addi	a0,a0,552 # 800268f0 <icache>
    800036d0:	ffffd097          	auipc	ra,0xffffd
    800036d4:	5e6080e7          	jalr	1510(ra) # 80000cb6 <release>
}
    800036d8:	854a                	mv	a0,s2
    800036da:	70a2                	ld	ra,40(sp)
    800036dc:	7402                	ld	s0,32(sp)
    800036de:	64e2                	ld	s1,24(sp)
    800036e0:	6942                	ld	s2,16(sp)
    800036e2:	69a2                	ld	s3,8(sp)
    800036e4:	6a02                	ld	s4,0(sp)
    800036e6:	6145                	addi	sp,sp,48
    800036e8:	8082                	ret
    panic("iget: no inodes");
    800036ea:	00005517          	auipc	a0,0x5
    800036ee:	fbe50513          	addi	a0,a0,-66 # 800086a8 <userret+0x618>
    800036f2:	ffffd097          	auipc	ra,0xffffd
    800036f6:	e8c080e7          	jalr	-372(ra) # 8000057e <panic>

00000000800036fa <fsinit>:
fsinit(int dev) {
    800036fa:	7179                	addi	sp,sp,-48
    800036fc:	f406                	sd	ra,40(sp)
    800036fe:	f022                	sd	s0,32(sp)
    80003700:	ec26                	sd	s1,24(sp)
    80003702:	e84a                	sd	s2,16(sp)
    80003704:	e44e                	sd	s3,8(sp)
    80003706:	1800                	addi	s0,sp,48
    80003708:	89aa                	mv	s3,a0
  bp = bread(dev, 1);
    8000370a:	4585                	li	a1,1
    8000370c:	00000097          	auipc	ra,0x0
    80003710:	916080e7          	jalr	-1770(ra) # 80003022 <bread>
    80003714:	892a                	mv	s2,a0
  memmove(sb, bp->data, sizeof(*sb));
    80003716:	00023497          	auipc	s1,0x23
    8000371a:	1ba48493          	addi	s1,s1,442 # 800268d0 <sb>
    8000371e:	02000613          	li	a2,32
    80003722:	06450593          	addi	a1,a0,100
    80003726:	8526                	mv	a0,s1
    80003728:	ffffe097          	auipc	ra,0xffffe
    8000372c:	820080e7          	jalr	-2016(ra) # 80000f48 <memmove>
  brelse(bp);
    80003730:	854a                	mv	a0,s2
    80003732:	00000097          	auipc	ra,0x0
    80003736:	b84080e7          	jalr	-1148(ra) # 800032b6 <brelse>
  if(sb.magic != FSMAGIC)
    8000373a:	4098                	lw	a4,0(s1)
    8000373c:	102037b7          	lui	a5,0x10203
    80003740:	04078793          	addi	a5,a5,64 # 10203040 <_entry-0x6fdfcfc0>
    80003744:	02f71263          	bne	a4,a5,80003768 <fsinit+0x6e>
  initlog(dev, &sb);
    80003748:	00023597          	auipc	a1,0x23
    8000374c:	18858593          	addi	a1,a1,392 # 800268d0 <sb>
    80003750:	854e                	mv	a0,s3
    80003752:	00001097          	auipc	ra,0x1
    80003756:	b46080e7          	jalr	-1210(ra) # 80004298 <initlog>
}
    8000375a:	70a2                	ld	ra,40(sp)
    8000375c:	7402                	ld	s0,32(sp)
    8000375e:	64e2                	ld	s1,24(sp)
    80003760:	6942                	ld	s2,16(sp)
    80003762:	69a2                	ld	s3,8(sp)
    80003764:	6145                	addi	sp,sp,48
    80003766:	8082                	ret
    panic("invalid file system");
    80003768:	00005517          	auipc	a0,0x5
    8000376c:	f5050513          	addi	a0,a0,-176 # 800086b8 <userret+0x628>
    80003770:	ffffd097          	auipc	ra,0xffffd
    80003774:	e0e080e7          	jalr	-498(ra) # 8000057e <panic>

0000000080003778 <iinit>:
{
    80003778:	7179                	addi	sp,sp,-48
    8000377a:	f406                	sd	ra,40(sp)
    8000377c:	f022                	sd	s0,32(sp)
    8000377e:	ec26                	sd	s1,24(sp)
    80003780:	e84a                	sd	s2,16(sp)
    80003782:	e44e                	sd	s3,8(sp)
    80003784:	1800                	addi	s0,sp,48
  initlock(&icache.lock, "icache");
    80003786:	00005597          	auipc	a1,0x5
    8000378a:	f4a58593          	addi	a1,a1,-182 # 800086d0 <userret+0x640>
    8000378e:	00023517          	auipc	a0,0x23
    80003792:	16250513          	addi	a0,a0,354 # 800268f0 <icache>
    80003796:	ffffd097          	auipc	ra,0xffffd
    8000379a:	360080e7          	jalr	864(ra) # 80000af6 <initlock>
  for(i = 0; i < NINODE; i++) {
    8000379e:	00023497          	auipc	s1,0x23
    800037a2:	18248493          	addi	s1,s1,386 # 80026920 <icache+0x30>
    800037a6:	00025997          	auipc	s3,0x25
    800037aa:	d9a98993          	addi	s3,s3,-614 # 80028540 <log+0x10>
    initsleeplock(&icache.inode[i].lock, "inode");
    800037ae:	00005917          	auipc	s2,0x5
    800037b2:	f2a90913          	addi	s2,s2,-214 # 800086d8 <userret+0x648>
    800037b6:	85ca                	mv	a1,s2
    800037b8:	8526                	mv	a0,s1
    800037ba:	00001097          	auipc	ra,0x1
    800037be:	f52080e7          	jalr	-174(ra) # 8000470c <initsleeplock>
  for(i = 0; i < NINODE; i++) {
    800037c2:	09048493          	addi	s1,s1,144
    800037c6:	ff3498e3          	bne	s1,s3,800037b6 <iinit+0x3e>
}
    800037ca:	70a2                	ld	ra,40(sp)
    800037cc:	7402                	ld	s0,32(sp)
    800037ce:	64e2                	ld	s1,24(sp)
    800037d0:	6942                	ld	s2,16(sp)
    800037d2:	69a2                	ld	s3,8(sp)
    800037d4:	6145                	addi	sp,sp,48
    800037d6:	8082                	ret

00000000800037d8 <ialloc>:
{
    800037d8:	715d                	addi	sp,sp,-80
    800037da:	e486                	sd	ra,72(sp)
    800037dc:	e0a2                	sd	s0,64(sp)
    800037de:	fc26                	sd	s1,56(sp)
    800037e0:	f84a                	sd	s2,48(sp)
    800037e2:	f44e                	sd	s3,40(sp)
    800037e4:	f052                	sd	s4,32(sp)
    800037e6:	ec56                	sd	s5,24(sp)
    800037e8:	e85a                	sd	s6,16(sp)
    800037ea:	e45e                	sd	s7,8(sp)
    800037ec:	0880                	addi	s0,sp,80
  for(inum = 1; inum < sb.ninodes; inum++){
    800037ee:	00023797          	auipc	a5,0x23
    800037f2:	0e278793          	addi	a5,a5,226 # 800268d0 <sb>
    800037f6:	47d8                	lw	a4,12(a5)
    800037f8:	4785                	li	a5,1
    800037fa:	04e7fa63          	bleu	a4,a5,8000384e <ialloc+0x76>
    800037fe:	8a2a                	mv	s4,a0
    80003800:	8b2e                	mv	s6,a1
    80003802:	4485                	li	s1,1
    bp = bread(dev, IBLOCK(inum, sb));
    80003804:	00023997          	auipc	s3,0x23
    80003808:	0cc98993          	addi	s3,s3,204 # 800268d0 <sb>
    8000380c:	00048a9b          	sext.w	s5,s1
    80003810:	0044d593          	srli	a1,s1,0x4
    80003814:	0189a783          	lw	a5,24(s3)
    80003818:	9dbd                	addw	a1,a1,a5
    8000381a:	8552                	mv	a0,s4
    8000381c:	00000097          	auipc	ra,0x0
    80003820:	806080e7          	jalr	-2042(ra) # 80003022 <bread>
    80003824:	8baa                	mv	s7,a0
    dip = (struct dinode*)bp->data + inum%IPB;
    80003826:	06450913          	addi	s2,a0,100
    8000382a:	00f4f793          	andi	a5,s1,15
    8000382e:	079a                	slli	a5,a5,0x6
    80003830:	993e                	add	s2,s2,a5
    if(dip->type == 0){  // a free inode
    80003832:	00091783          	lh	a5,0(s2)
    80003836:	c785                	beqz	a5,8000385e <ialloc+0x86>
    brelse(bp);
    80003838:	00000097          	auipc	ra,0x0
    8000383c:	a7e080e7          	jalr	-1410(ra) # 800032b6 <brelse>
  for(inum = 1; inum < sb.ninodes; inum++){
    80003840:	0485                	addi	s1,s1,1
    80003842:	00c9a703          	lw	a4,12(s3)
    80003846:	0004879b          	sext.w	a5,s1
    8000384a:	fce7e1e3          	bltu	a5,a4,8000380c <ialloc+0x34>
  panic("ialloc: no inodes");
    8000384e:	00005517          	auipc	a0,0x5
    80003852:	e9250513          	addi	a0,a0,-366 # 800086e0 <userret+0x650>
    80003856:	ffffd097          	auipc	ra,0xffffd
    8000385a:	d28080e7          	jalr	-728(ra) # 8000057e <panic>
      memset(dip, 0, sizeof(*dip));
    8000385e:	04000613          	li	a2,64
    80003862:	4581                	li	a1,0
    80003864:	854a                	mv	a0,s2
    80003866:	ffffd097          	auipc	ra,0xffffd
    8000386a:	676080e7          	jalr	1654(ra) # 80000edc <memset>
      dip->type = type;
    8000386e:	01691023          	sh	s6,0(s2)
      log_write(bp);   // mark it allocated on the disk
    80003872:	855e                	mv	a0,s7
    80003874:	00001097          	auipc	ra,0x1
    80003878:	d3a080e7          	jalr	-710(ra) # 800045ae <log_write>
      brelse(bp);
    8000387c:	855e                	mv	a0,s7
    8000387e:	00000097          	auipc	ra,0x0
    80003882:	a38080e7          	jalr	-1480(ra) # 800032b6 <brelse>
      return iget(dev, inum);
    80003886:	85d6                	mv	a1,s5
    80003888:	8552                	mv	a0,s4
    8000388a:	00000097          	auipc	ra,0x0
    8000388e:	db4080e7          	jalr	-588(ra) # 8000363e <iget>
}
    80003892:	60a6                	ld	ra,72(sp)
    80003894:	6406                	ld	s0,64(sp)
    80003896:	74e2                	ld	s1,56(sp)
    80003898:	7942                	ld	s2,48(sp)
    8000389a:	79a2                	ld	s3,40(sp)
    8000389c:	7a02                	ld	s4,32(sp)
    8000389e:	6ae2                	ld	s5,24(sp)
    800038a0:	6b42                	ld	s6,16(sp)
    800038a2:	6ba2                	ld	s7,8(sp)
    800038a4:	6161                	addi	sp,sp,80
    800038a6:	8082                	ret

00000000800038a8 <iupdate>:
{
    800038a8:	1101                	addi	sp,sp,-32
    800038aa:	ec06                	sd	ra,24(sp)
    800038ac:	e822                	sd	s0,16(sp)
    800038ae:	e426                	sd	s1,8(sp)
    800038b0:	e04a                	sd	s2,0(sp)
    800038b2:	1000                	addi	s0,sp,32
    800038b4:	84aa                	mv	s1,a0
  bp = bread(ip->dev, IBLOCK(ip->inum, sb));
    800038b6:	415c                	lw	a5,4(a0)
    800038b8:	0047d79b          	srliw	a5,a5,0x4
    800038bc:	00023717          	auipc	a4,0x23
    800038c0:	01470713          	addi	a4,a4,20 # 800268d0 <sb>
    800038c4:	4f0c                	lw	a1,24(a4)
    800038c6:	9dbd                	addw	a1,a1,a5
    800038c8:	4108                	lw	a0,0(a0)
    800038ca:	fffff097          	auipc	ra,0xfffff
    800038ce:	758080e7          	jalr	1880(ra) # 80003022 <bread>
    800038d2:	892a                	mv	s2,a0
  dip = (struct dinode*)bp->data + ip->inum%IPB;
    800038d4:	06450513          	addi	a0,a0,100
    800038d8:	40dc                	lw	a5,4(s1)
    800038da:	8bbd                	andi	a5,a5,15
    800038dc:	079a                	slli	a5,a5,0x6
    800038de:	953e                	add	a0,a0,a5
  dip->type = ip->type;
    800038e0:	04c49783          	lh	a5,76(s1)
    800038e4:	00f51023          	sh	a5,0(a0)
  dip->major = ip->major;
    800038e8:	04e49783          	lh	a5,78(s1)
    800038ec:	00f51123          	sh	a5,2(a0)
  dip->minor = ip->minor;
    800038f0:	05049783          	lh	a5,80(s1)
    800038f4:	00f51223          	sh	a5,4(a0)
  dip->nlink = ip->nlink;
    800038f8:	05249783          	lh	a5,82(s1)
    800038fc:	00f51323          	sh	a5,6(a0)
  dip->size = ip->size;
    80003900:	48fc                	lw	a5,84(s1)
    80003902:	c51c                	sw	a5,8(a0)
  memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
    80003904:	03400613          	li	a2,52
    80003908:	05848593          	addi	a1,s1,88
    8000390c:	0531                	addi	a0,a0,12
    8000390e:	ffffd097          	auipc	ra,0xffffd
    80003912:	63a080e7          	jalr	1594(ra) # 80000f48 <memmove>
  log_write(bp);
    80003916:	854a                	mv	a0,s2
    80003918:	00001097          	auipc	ra,0x1
    8000391c:	c96080e7          	jalr	-874(ra) # 800045ae <log_write>
  brelse(bp);
    80003920:	854a                	mv	a0,s2
    80003922:	00000097          	auipc	ra,0x0
    80003926:	994080e7          	jalr	-1644(ra) # 800032b6 <brelse>
}
    8000392a:	60e2                	ld	ra,24(sp)
    8000392c:	6442                	ld	s0,16(sp)
    8000392e:	64a2                	ld	s1,8(sp)
    80003930:	6902                	ld	s2,0(sp)
    80003932:	6105                	addi	sp,sp,32
    80003934:	8082                	ret

0000000080003936 <idup>:
{
    80003936:	1101                	addi	sp,sp,-32
    80003938:	ec06                	sd	ra,24(sp)
    8000393a:	e822                	sd	s0,16(sp)
    8000393c:	e426                	sd	s1,8(sp)
    8000393e:	1000                	addi	s0,sp,32
    80003940:	84aa                	mv	s1,a0
  acquire(&icache.lock);
    80003942:	00023517          	auipc	a0,0x23
    80003946:	fae50513          	addi	a0,a0,-82 # 800268f0 <icache>
    8000394a:	ffffd097          	auipc	ra,0xffffd
    8000394e:	2fc080e7          	jalr	764(ra) # 80000c46 <acquire>
  ip->ref++;
    80003952:	449c                	lw	a5,8(s1)
    80003954:	2785                	addiw	a5,a5,1
    80003956:	c49c                	sw	a5,8(s1)
  release(&icache.lock);
    80003958:	00023517          	auipc	a0,0x23
    8000395c:	f9850513          	addi	a0,a0,-104 # 800268f0 <icache>
    80003960:	ffffd097          	auipc	ra,0xffffd
    80003964:	356080e7          	jalr	854(ra) # 80000cb6 <release>
}
    80003968:	8526                	mv	a0,s1
    8000396a:	60e2                	ld	ra,24(sp)
    8000396c:	6442                	ld	s0,16(sp)
    8000396e:	64a2                	ld	s1,8(sp)
    80003970:	6105                	addi	sp,sp,32
    80003972:	8082                	ret

0000000080003974 <ilock>:
{
    80003974:	1101                	addi	sp,sp,-32
    80003976:	ec06                	sd	ra,24(sp)
    80003978:	e822                	sd	s0,16(sp)
    8000397a:	e426                	sd	s1,8(sp)
    8000397c:	e04a                	sd	s2,0(sp)
    8000397e:	1000                	addi	s0,sp,32
  if(ip == 0 || ip->ref < 1)
    80003980:	c115                	beqz	a0,800039a4 <ilock+0x30>
    80003982:	84aa                	mv	s1,a0
    80003984:	451c                	lw	a5,8(a0)
    80003986:	00f05f63          	blez	a5,800039a4 <ilock+0x30>
  acquiresleep(&ip->lock);
    8000398a:	0541                	addi	a0,a0,16
    8000398c:	00001097          	auipc	ra,0x1
    80003990:	dba080e7          	jalr	-582(ra) # 80004746 <acquiresleep>
  if(ip->valid == 0){
    80003994:	44bc                	lw	a5,72(s1)
    80003996:	cf99                	beqz	a5,800039b4 <ilock+0x40>
}
    80003998:	60e2                	ld	ra,24(sp)
    8000399a:	6442                	ld	s0,16(sp)
    8000399c:	64a2                	ld	s1,8(sp)
    8000399e:	6902                	ld	s2,0(sp)
    800039a0:	6105                	addi	sp,sp,32
    800039a2:	8082                	ret
    panic("ilock");
    800039a4:	00005517          	auipc	a0,0x5
    800039a8:	d5450513          	addi	a0,a0,-684 # 800086f8 <userret+0x668>
    800039ac:	ffffd097          	auipc	ra,0xffffd
    800039b0:	bd2080e7          	jalr	-1070(ra) # 8000057e <panic>
    bp = bread(ip->dev, IBLOCK(ip->inum, sb));
    800039b4:	40dc                	lw	a5,4(s1)
    800039b6:	0047d79b          	srliw	a5,a5,0x4
    800039ba:	00023717          	auipc	a4,0x23
    800039be:	f1670713          	addi	a4,a4,-234 # 800268d0 <sb>
    800039c2:	4f0c                	lw	a1,24(a4)
    800039c4:	9dbd                	addw	a1,a1,a5
    800039c6:	4088                	lw	a0,0(s1)
    800039c8:	fffff097          	auipc	ra,0xfffff
    800039cc:	65a080e7          	jalr	1626(ra) # 80003022 <bread>
    800039d0:	892a                	mv	s2,a0
    dip = (struct dinode*)bp->data + ip->inum%IPB;
    800039d2:	06450593          	addi	a1,a0,100
    800039d6:	40dc                	lw	a5,4(s1)
    800039d8:	8bbd                	andi	a5,a5,15
    800039da:	079a                	slli	a5,a5,0x6
    800039dc:	95be                	add	a1,a1,a5
    ip->type = dip->type;
    800039de:	00059783          	lh	a5,0(a1)
    800039e2:	04f49623          	sh	a5,76(s1)
    ip->major = dip->major;
    800039e6:	00259783          	lh	a5,2(a1)
    800039ea:	04f49723          	sh	a5,78(s1)
    ip->minor = dip->minor;
    800039ee:	00459783          	lh	a5,4(a1)
    800039f2:	04f49823          	sh	a5,80(s1)
    ip->nlink = dip->nlink;
    800039f6:	00659783          	lh	a5,6(a1)
    800039fa:	04f49923          	sh	a5,82(s1)
    ip->size = dip->size;
    800039fe:	459c                	lw	a5,8(a1)
    80003a00:	c8fc                	sw	a5,84(s1)
    memmove(ip->addrs, dip->addrs, sizeof(ip->addrs));
    80003a02:	03400613          	li	a2,52
    80003a06:	05b1                	addi	a1,a1,12
    80003a08:	05848513          	addi	a0,s1,88
    80003a0c:	ffffd097          	auipc	ra,0xffffd
    80003a10:	53c080e7          	jalr	1340(ra) # 80000f48 <memmove>
    brelse(bp);
    80003a14:	854a                	mv	a0,s2
    80003a16:	00000097          	auipc	ra,0x0
    80003a1a:	8a0080e7          	jalr	-1888(ra) # 800032b6 <brelse>
    ip->valid = 1;
    80003a1e:	4785                	li	a5,1
    80003a20:	c4bc                	sw	a5,72(s1)
    if(ip->type == 0)
    80003a22:	04c49783          	lh	a5,76(s1)
    80003a26:	fbad                	bnez	a5,80003998 <ilock+0x24>
      panic("ilock: no type");
    80003a28:	00005517          	auipc	a0,0x5
    80003a2c:	cd850513          	addi	a0,a0,-808 # 80008700 <userret+0x670>
    80003a30:	ffffd097          	auipc	ra,0xffffd
    80003a34:	b4e080e7          	jalr	-1202(ra) # 8000057e <panic>

0000000080003a38 <iunlock>:
{
    80003a38:	1101                	addi	sp,sp,-32
    80003a3a:	ec06                	sd	ra,24(sp)
    80003a3c:	e822                	sd	s0,16(sp)
    80003a3e:	e426                	sd	s1,8(sp)
    80003a40:	e04a                	sd	s2,0(sp)
    80003a42:	1000                	addi	s0,sp,32
  if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1)
    80003a44:	c905                	beqz	a0,80003a74 <iunlock+0x3c>
    80003a46:	84aa                	mv	s1,a0
    80003a48:	01050913          	addi	s2,a0,16
    80003a4c:	854a                	mv	a0,s2
    80003a4e:	00001097          	auipc	ra,0x1
    80003a52:	d92080e7          	jalr	-622(ra) # 800047e0 <holdingsleep>
    80003a56:	cd19                	beqz	a0,80003a74 <iunlock+0x3c>
    80003a58:	449c                	lw	a5,8(s1)
    80003a5a:	00f05d63          	blez	a5,80003a74 <iunlock+0x3c>
  releasesleep(&ip->lock);
    80003a5e:	854a                	mv	a0,s2
    80003a60:	00001097          	auipc	ra,0x1
    80003a64:	d3c080e7          	jalr	-708(ra) # 8000479c <releasesleep>
}
    80003a68:	60e2                	ld	ra,24(sp)
    80003a6a:	6442                	ld	s0,16(sp)
    80003a6c:	64a2                	ld	s1,8(sp)
    80003a6e:	6902                	ld	s2,0(sp)
    80003a70:	6105                	addi	sp,sp,32
    80003a72:	8082                	ret
    panic("iunlock");
    80003a74:	00005517          	auipc	a0,0x5
    80003a78:	c9c50513          	addi	a0,a0,-868 # 80008710 <userret+0x680>
    80003a7c:	ffffd097          	auipc	ra,0xffffd
    80003a80:	b02080e7          	jalr	-1278(ra) # 8000057e <panic>

0000000080003a84 <iput>:
{
    80003a84:	7139                	addi	sp,sp,-64
    80003a86:	fc06                	sd	ra,56(sp)
    80003a88:	f822                	sd	s0,48(sp)
    80003a8a:	f426                	sd	s1,40(sp)
    80003a8c:	f04a                	sd	s2,32(sp)
    80003a8e:	ec4e                	sd	s3,24(sp)
    80003a90:	e852                	sd	s4,16(sp)
    80003a92:	e456                	sd	s5,8(sp)
    80003a94:	0080                	addi	s0,sp,64
    80003a96:	84aa                	mv	s1,a0
  acquire(&icache.lock);
    80003a98:	00023517          	auipc	a0,0x23
    80003a9c:	e5850513          	addi	a0,a0,-424 # 800268f0 <icache>
    80003aa0:	ffffd097          	auipc	ra,0xffffd
    80003aa4:	1a6080e7          	jalr	422(ra) # 80000c46 <acquire>
  if(ip->ref == 1 && ip->valid && ip->nlink == 0){
    80003aa8:	4498                	lw	a4,8(s1)
    80003aaa:	4785                	li	a5,1
    80003aac:	02f70663          	beq	a4,a5,80003ad8 <iput+0x54>
  ip->ref--;
    80003ab0:	449c                	lw	a5,8(s1)
    80003ab2:	37fd                	addiw	a5,a5,-1
    80003ab4:	c49c                	sw	a5,8(s1)
  release(&icache.lock);
    80003ab6:	00023517          	auipc	a0,0x23
    80003aba:	e3a50513          	addi	a0,a0,-454 # 800268f0 <icache>
    80003abe:	ffffd097          	auipc	ra,0xffffd
    80003ac2:	1f8080e7          	jalr	504(ra) # 80000cb6 <release>
}
    80003ac6:	70e2                	ld	ra,56(sp)
    80003ac8:	7442                	ld	s0,48(sp)
    80003aca:	74a2                	ld	s1,40(sp)
    80003acc:	7902                	ld	s2,32(sp)
    80003ace:	69e2                	ld	s3,24(sp)
    80003ad0:	6a42                	ld	s4,16(sp)
    80003ad2:	6aa2                	ld	s5,8(sp)
    80003ad4:	6121                	addi	sp,sp,64
    80003ad6:	8082                	ret
  if(ip->ref == 1 && ip->valid && ip->nlink == 0){
    80003ad8:	44bc                	lw	a5,72(s1)
    80003ada:	dbf9                	beqz	a5,80003ab0 <iput+0x2c>
    80003adc:	05249783          	lh	a5,82(s1)
    80003ae0:	fbe1                	bnez	a5,80003ab0 <iput+0x2c>
    acquiresleep(&ip->lock);
    80003ae2:	01048a13          	addi	s4,s1,16
    80003ae6:	8552                	mv	a0,s4
    80003ae8:	00001097          	auipc	ra,0x1
    80003aec:	c5e080e7          	jalr	-930(ra) # 80004746 <acquiresleep>
    release(&icache.lock);
    80003af0:	00023517          	auipc	a0,0x23
    80003af4:	e0050513          	addi	a0,a0,-512 # 800268f0 <icache>
    80003af8:	ffffd097          	auipc	ra,0xffffd
    80003afc:	1be080e7          	jalr	446(ra) # 80000cb6 <release>
{
  int i, j;
  struct buf *bp;
  uint *a;

  for(i = 0; i < NDIRECT; i++){
    80003b00:	05848913          	addi	s2,s1,88
    80003b04:	08848993          	addi	s3,s1,136
    80003b08:	a819                	j	80003b1e <iput+0x9a>
    if(ip->addrs[i]){
      bfree(ip->dev, ip->addrs[i]);
    80003b0a:	4088                	lw	a0,0(s1)
    80003b0c:	00000097          	auipc	ra,0x0
    80003b10:	878080e7          	jalr	-1928(ra) # 80003384 <bfree>
      ip->addrs[i] = 0;
    80003b14:	00092023          	sw	zero,0(s2)
  for(i = 0; i < NDIRECT; i++){
    80003b18:	0911                	addi	s2,s2,4
    80003b1a:	01390663          	beq	s2,s3,80003b26 <iput+0xa2>
    if(ip->addrs[i]){
    80003b1e:	00092583          	lw	a1,0(s2)
    80003b22:	d9fd                	beqz	a1,80003b18 <iput+0x94>
    80003b24:	b7dd                	j	80003b0a <iput+0x86>
    }
  }

  if(ip->addrs[NDIRECT]){
    80003b26:	0884a583          	lw	a1,136(s1)
    80003b2a:	ed9d                	bnez	a1,80003b68 <iput+0xe4>
    brelse(bp);
    bfree(ip->dev, ip->addrs[NDIRECT]);
    ip->addrs[NDIRECT] = 0;
  }

  ip->size = 0;
    80003b2c:	0404aa23          	sw	zero,84(s1)
  iupdate(ip);
    80003b30:	8526                	mv	a0,s1
    80003b32:	00000097          	auipc	ra,0x0
    80003b36:	d76080e7          	jalr	-650(ra) # 800038a8 <iupdate>
    ip->type = 0;
    80003b3a:	04049623          	sh	zero,76(s1)
    iupdate(ip);
    80003b3e:	8526                	mv	a0,s1
    80003b40:	00000097          	auipc	ra,0x0
    80003b44:	d68080e7          	jalr	-664(ra) # 800038a8 <iupdate>
    ip->valid = 0;
    80003b48:	0404a423          	sw	zero,72(s1)
    releasesleep(&ip->lock);
    80003b4c:	8552                	mv	a0,s4
    80003b4e:	00001097          	auipc	ra,0x1
    80003b52:	c4e080e7          	jalr	-946(ra) # 8000479c <releasesleep>
    acquire(&icache.lock);
    80003b56:	00023517          	auipc	a0,0x23
    80003b5a:	d9a50513          	addi	a0,a0,-614 # 800268f0 <icache>
    80003b5e:	ffffd097          	auipc	ra,0xffffd
    80003b62:	0e8080e7          	jalr	232(ra) # 80000c46 <acquire>
    80003b66:	b7a9                	j	80003ab0 <iput+0x2c>
    bp = bread(ip->dev, ip->addrs[NDIRECT]);
    80003b68:	4088                	lw	a0,0(s1)
    80003b6a:	fffff097          	auipc	ra,0xfffff
    80003b6e:	4b8080e7          	jalr	1208(ra) # 80003022 <bread>
    80003b72:	8aaa                	mv	s5,a0
    for(j = 0; j < NINDIRECT; j++){
    80003b74:	06450913          	addi	s2,a0,100
    80003b78:	46450993          	addi	s3,a0,1124
    80003b7c:	a809                	j	80003b8e <iput+0x10a>
        bfree(ip->dev, a[j]);
    80003b7e:	4088                	lw	a0,0(s1)
    80003b80:	00000097          	auipc	ra,0x0
    80003b84:	804080e7          	jalr	-2044(ra) # 80003384 <bfree>
    for(j = 0; j < NINDIRECT; j++){
    80003b88:	0911                	addi	s2,s2,4
    80003b8a:	01390663          	beq	s2,s3,80003b96 <iput+0x112>
      if(a[j])
    80003b8e:	00092583          	lw	a1,0(s2)
    80003b92:	d9fd                	beqz	a1,80003b88 <iput+0x104>
    80003b94:	b7ed                	j	80003b7e <iput+0xfa>
    brelse(bp);
    80003b96:	8556                	mv	a0,s5
    80003b98:	fffff097          	auipc	ra,0xfffff
    80003b9c:	71e080e7          	jalr	1822(ra) # 800032b6 <brelse>
    bfree(ip->dev, ip->addrs[NDIRECT]);
    80003ba0:	0884a583          	lw	a1,136(s1)
    80003ba4:	4088                	lw	a0,0(s1)
    80003ba6:	fffff097          	auipc	ra,0xfffff
    80003baa:	7de080e7          	jalr	2014(ra) # 80003384 <bfree>
    ip->addrs[NDIRECT] = 0;
    80003bae:	0804a423          	sw	zero,136(s1)
    80003bb2:	bfad                	j	80003b2c <iput+0xa8>

0000000080003bb4 <iunlockput>:
{
    80003bb4:	1101                	addi	sp,sp,-32
    80003bb6:	ec06                	sd	ra,24(sp)
    80003bb8:	e822                	sd	s0,16(sp)
    80003bba:	e426                	sd	s1,8(sp)
    80003bbc:	1000                	addi	s0,sp,32
    80003bbe:	84aa                	mv	s1,a0
  iunlock(ip);
    80003bc0:	00000097          	auipc	ra,0x0
    80003bc4:	e78080e7          	jalr	-392(ra) # 80003a38 <iunlock>
  iput(ip);
    80003bc8:	8526                	mv	a0,s1
    80003bca:	00000097          	auipc	ra,0x0
    80003bce:	eba080e7          	jalr	-326(ra) # 80003a84 <iput>
}
    80003bd2:	60e2                	ld	ra,24(sp)
    80003bd4:	6442                	ld	s0,16(sp)
    80003bd6:	64a2                	ld	s1,8(sp)
    80003bd8:	6105                	addi	sp,sp,32
    80003bda:	8082                	ret

0000000080003bdc <stati>:

// Copy stat information from inode.
// Caller must hold ip->lock.
void
stati(struct inode *ip, struct stat *st)
{
    80003bdc:	1141                	addi	sp,sp,-16
    80003bde:	e422                	sd	s0,8(sp)
    80003be0:	0800                	addi	s0,sp,16
  st->dev = ip->dev;
    80003be2:	411c                	lw	a5,0(a0)
    80003be4:	c19c                	sw	a5,0(a1)
  st->ino = ip->inum;
    80003be6:	415c                	lw	a5,4(a0)
    80003be8:	c1dc                	sw	a5,4(a1)
  st->type = ip->type;
    80003bea:	04c51783          	lh	a5,76(a0)
    80003bee:	00f59423          	sh	a5,8(a1)
  st->nlink = ip->nlink;
    80003bf2:	05251783          	lh	a5,82(a0)
    80003bf6:	00f59523          	sh	a5,10(a1)
  st->size = ip->size;
    80003bfa:	05456783          	lwu	a5,84(a0)
    80003bfe:	e99c                	sd	a5,16(a1)
}
    80003c00:	6422                	ld	s0,8(sp)
    80003c02:	0141                	addi	sp,sp,16
    80003c04:	8082                	ret

0000000080003c06 <readi>:
readi(struct inode *ip, int user_dst, uint64 dst, uint off, uint n)
{
  uint tot, m;
  struct buf *bp;

  if(off > ip->size || off + n < off)
    80003c06:	497c                	lw	a5,84(a0)
    80003c08:	0ed7e563          	bltu	a5,a3,80003cf2 <readi+0xec>
{
    80003c0c:	7159                	addi	sp,sp,-112
    80003c0e:	f486                	sd	ra,104(sp)
    80003c10:	f0a2                	sd	s0,96(sp)
    80003c12:	eca6                	sd	s1,88(sp)
    80003c14:	e8ca                	sd	s2,80(sp)
    80003c16:	e4ce                	sd	s3,72(sp)
    80003c18:	e0d2                	sd	s4,64(sp)
    80003c1a:	fc56                	sd	s5,56(sp)
    80003c1c:	f85a                	sd	s6,48(sp)
    80003c1e:	f45e                	sd	s7,40(sp)
    80003c20:	f062                	sd	s8,32(sp)
    80003c22:	ec66                	sd	s9,24(sp)
    80003c24:	e86a                	sd	s10,16(sp)
    80003c26:	e46e                	sd	s11,8(sp)
    80003c28:	1880                	addi	s0,sp,112
    80003c2a:	8baa                	mv	s7,a0
    80003c2c:	8c2e                	mv	s8,a1
    80003c2e:	8a32                	mv	s4,a2
    80003c30:	84b6                	mv	s1,a3
    80003c32:	8b3a                	mv	s6,a4
  if(off > ip->size || off + n < off)
    80003c34:	9f35                	addw	a4,a4,a3
    80003c36:	0cd76063          	bltu	a4,a3,80003cf6 <readi+0xf0>
    return -1;
  if(off + n > ip->size)
    80003c3a:	00e7f463          	bleu	a4,a5,80003c42 <readi+0x3c>
    n = ip->size - off;
    80003c3e:	40d78b3b          	subw	s6,a5,a3

  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    80003c42:	080b0763          	beqz	s6,80003cd0 <readi+0xca>
    80003c46:	4981                	li	s3,0
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    80003c48:	40000d13          	li	s10,1024
    if(either_copyout(user_dst, dst, bp->data + (off % BSIZE), m) == -1) {
    80003c4c:	5cfd                	li	s9,-1
    80003c4e:	a82d                	j	80003c88 <readi+0x82>
    80003c50:	02091d93          	slli	s11,s2,0x20
    80003c54:	020ddd93          	srli	s11,s11,0x20
    80003c58:	064a8613          	addi	a2,s5,100
    80003c5c:	86ee                	mv	a3,s11
    80003c5e:	963a                	add	a2,a2,a4
    80003c60:	85d2                	mv	a1,s4
    80003c62:	8562                	mv	a0,s8
    80003c64:	fffff097          	auipc	ra,0xfffff
    80003c68:	9e0080e7          	jalr	-1568(ra) # 80002644 <either_copyout>
    80003c6c:	05950d63          	beq	a0,s9,80003cc6 <readi+0xc0>
      brelse(bp);
      break;
    }
    brelse(bp);
    80003c70:	8556                	mv	a0,s5
    80003c72:	fffff097          	auipc	ra,0xfffff
    80003c76:	644080e7          	jalr	1604(ra) # 800032b6 <brelse>
  for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
    80003c7a:	013909bb          	addw	s3,s2,s3
    80003c7e:	009904bb          	addw	s1,s2,s1
    80003c82:	9a6e                	add	s4,s4,s11
    80003c84:	0569f663          	bleu	s6,s3,80003cd0 <readi+0xca>
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    80003c88:	000ba903          	lw	s2,0(s7)
    80003c8c:	00a4d59b          	srliw	a1,s1,0xa
    80003c90:	855e                	mv	a0,s7
    80003c92:	00000097          	auipc	ra,0x0
    80003c96:	8d2080e7          	jalr	-1838(ra) # 80003564 <bmap>
    80003c9a:	0005059b          	sext.w	a1,a0
    80003c9e:	854a                	mv	a0,s2
    80003ca0:	fffff097          	auipc	ra,0xfffff
    80003ca4:	382080e7          	jalr	898(ra) # 80003022 <bread>
    80003ca8:	8aaa                	mv	s5,a0
    m = min(n - tot, BSIZE - off%BSIZE);
    80003caa:	3ff4f713          	andi	a4,s1,1023
    80003cae:	40ed07bb          	subw	a5,s10,a4
    80003cb2:	413b06bb          	subw	a3,s6,s3
    80003cb6:	893e                	mv	s2,a5
    80003cb8:	2781                	sext.w	a5,a5
    80003cba:	0006861b          	sext.w	a2,a3
    80003cbe:	f8f679e3          	bleu	a5,a2,80003c50 <readi+0x4a>
    80003cc2:	8936                	mv	s2,a3
    80003cc4:	b771                	j	80003c50 <readi+0x4a>
      brelse(bp);
    80003cc6:	8556                	mv	a0,s5
    80003cc8:	fffff097          	auipc	ra,0xfffff
    80003ccc:	5ee080e7          	jalr	1518(ra) # 800032b6 <brelse>
  }
  return n;
    80003cd0:	000b051b          	sext.w	a0,s6
}
    80003cd4:	70a6                	ld	ra,104(sp)
    80003cd6:	7406                	ld	s0,96(sp)
    80003cd8:	64e6                	ld	s1,88(sp)
    80003cda:	6946                	ld	s2,80(sp)
    80003cdc:	69a6                	ld	s3,72(sp)
    80003cde:	6a06                	ld	s4,64(sp)
    80003ce0:	7ae2                	ld	s5,56(sp)
    80003ce2:	7b42                	ld	s6,48(sp)
    80003ce4:	7ba2                	ld	s7,40(sp)
    80003ce6:	7c02                	ld	s8,32(sp)
    80003ce8:	6ce2                	ld	s9,24(sp)
    80003cea:	6d42                	ld	s10,16(sp)
    80003cec:	6da2                	ld	s11,8(sp)
    80003cee:	6165                	addi	sp,sp,112
    80003cf0:	8082                	ret
    return -1;
    80003cf2:	557d                	li	a0,-1
}
    80003cf4:	8082                	ret
    return -1;
    80003cf6:	557d                	li	a0,-1
    80003cf8:	bff1                	j	80003cd4 <readi+0xce>

0000000080003cfa <writei>:
writei(struct inode *ip, int user_src, uint64 src, uint off, uint n)
{
  uint tot, m;
  struct buf *bp;

  if(off > ip->size || off + n < off)
    80003cfa:	497c                	lw	a5,84(a0)
    80003cfc:	10d7e663          	bltu	a5,a3,80003e08 <writei+0x10e>
{
    80003d00:	7159                	addi	sp,sp,-112
    80003d02:	f486                	sd	ra,104(sp)
    80003d04:	f0a2                	sd	s0,96(sp)
    80003d06:	eca6                	sd	s1,88(sp)
    80003d08:	e8ca                	sd	s2,80(sp)
    80003d0a:	e4ce                	sd	s3,72(sp)
    80003d0c:	e0d2                	sd	s4,64(sp)
    80003d0e:	fc56                	sd	s5,56(sp)
    80003d10:	f85a                	sd	s6,48(sp)
    80003d12:	f45e                	sd	s7,40(sp)
    80003d14:	f062                	sd	s8,32(sp)
    80003d16:	ec66                	sd	s9,24(sp)
    80003d18:	e86a                	sd	s10,16(sp)
    80003d1a:	e46e                	sd	s11,8(sp)
    80003d1c:	1880                	addi	s0,sp,112
    80003d1e:	8baa                	mv	s7,a0
    80003d20:	8c2e                	mv	s8,a1
    80003d22:	8ab2                	mv	s5,a2
    80003d24:	84b6                	mv	s1,a3
    80003d26:	8b3a                	mv	s6,a4
  if(off > ip->size || off + n < off)
    80003d28:	00e687bb          	addw	a5,a3,a4
    80003d2c:	0ed7e063          	bltu	a5,a3,80003e0c <writei+0x112>
    return -1;
  if(off + n > MAXFILE*BSIZE)
    80003d30:	00043737          	lui	a4,0x43
    80003d34:	0cf76e63          	bltu	a4,a5,80003e10 <writei+0x116>
    return -1;

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    80003d38:	0a0b0763          	beqz	s6,80003de6 <writei+0xec>
    80003d3c:	4a01                	li	s4,0
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    80003d3e:	40000d13          	li	s10,1024
    if(either_copyin(bp->data + (off % BSIZE), user_src, src, m) == -1) {
    80003d42:	5cfd                	li	s9,-1
    80003d44:	a091                	j	80003d88 <writei+0x8e>
    80003d46:	02091d93          	slli	s11,s2,0x20
    80003d4a:	020ddd93          	srli	s11,s11,0x20
    80003d4e:	06498513          	addi	a0,s3,100
    80003d52:	86ee                	mv	a3,s11
    80003d54:	8656                	mv	a2,s5
    80003d56:	85e2                	mv	a1,s8
    80003d58:	953a                	add	a0,a0,a4
    80003d5a:	fffff097          	auipc	ra,0xfffff
    80003d5e:	940080e7          	jalr	-1728(ra) # 8000269a <either_copyin>
    80003d62:	07950263          	beq	a0,s9,80003dc6 <writei+0xcc>
      brelse(bp);
      break;
    }
    log_write(bp);
    80003d66:	854e                	mv	a0,s3
    80003d68:	00001097          	auipc	ra,0x1
    80003d6c:	846080e7          	jalr	-1978(ra) # 800045ae <log_write>
    brelse(bp);
    80003d70:	854e                	mv	a0,s3
    80003d72:	fffff097          	auipc	ra,0xfffff
    80003d76:	544080e7          	jalr	1348(ra) # 800032b6 <brelse>
  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    80003d7a:	01490a3b          	addw	s4,s2,s4
    80003d7e:	009904bb          	addw	s1,s2,s1
    80003d82:	9aee                	add	s5,s5,s11
    80003d84:	056a7663          	bleu	s6,s4,80003dd0 <writei+0xd6>
    bp = bread(ip->dev, bmap(ip, off/BSIZE));
    80003d88:	000ba903          	lw	s2,0(s7)
    80003d8c:	00a4d59b          	srliw	a1,s1,0xa
    80003d90:	855e                	mv	a0,s7
    80003d92:	fffff097          	auipc	ra,0xfffff
    80003d96:	7d2080e7          	jalr	2002(ra) # 80003564 <bmap>
    80003d9a:	0005059b          	sext.w	a1,a0
    80003d9e:	854a                	mv	a0,s2
    80003da0:	fffff097          	auipc	ra,0xfffff
    80003da4:	282080e7          	jalr	642(ra) # 80003022 <bread>
    80003da8:	89aa                	mv	s3,a0
    m = min(n - tot, BSIZE - off%BSIZE);
    80003daa:	3ff4f713          	andi	a4,s1,1023
    80003dae:	40ed07bb          	subw	a5,s10,a4
    80003db2:	414b06bb          	subw	a3,s6,s4
    80003db6:	893e                	mv	s2,a5
    80003db8:	2781                	sext.w	a5,a5
    80003dba:	0006861b          	sext.w	a2,a3
    80003dbe:	f8f674e3          	bleu	a5,a2,80003d46 <writei+0x4c>
    80003dc2:	8936                	mv	s2,a3
    80003dc4:	b749                	j	80003d46 <writei+0x4c>
      brelse(bp);
    80003dc6:	854e                	mv	a0,s3
    80003dc8:	fffff097          	auipc	ra,0xfffff
    80003dcc:	4ee080e7          	jalr	1262(ra) # 800032b6 <brelse>
  }

  if(n > 0){
    if(off > ip->size)
    80003dd0:	054ba783          	lw	a5,84(s7)
    80003dd4:	0097f463          	bleu	s1,a5,80003ddc <writei+0xe2>
      ip->size = off;
    80003dd8:	049baa23          	sw	s1,84(s7)
    // write the i-node back to disk even if the size didn't change
    // because the loop above might have called bmap() and added a new
    // block to ip->addrs[].
    iupdate(ip);
    80003ddc:	855e                	mv	a0,s7
    80003dde:	00000097          	auipc	ra,0x0
    80003de2:	aca080e7          	jalr	-1334(ra) # 800038a8 <iupdate>
  }

  return n;
    80003de6:	000b051b          	sext.w	a0,s6
}
    80003dea:	70a6                	ld	ra,104(sp)
    80003dec:	7406                	ld	s0,96(sp)
    80003dee:	64e6                	ld	s1,88(sp)
    80003df0:	6946                	ld	s2,80(sp)
    80003df2:	69a6                	ld	s3,72(sp)
    80003df4:	6a06                	ld	s4,64(sp)
    80003df6:	7ae2                	ld	s5,56(sp)
    80003df8:	7b42                	ld	s6,48(sp)
    80003dfa:	7ba2                	ld	s7,40(sp)
    80003dfc:	7c02                	ld	s8,32(sp)
    80003dfe:	6ce2                	ld	s9,24(sp)
    80003e00:	6d42                	ld	s10,16(sp)
    80003e02:	6da2                	ld	s11,8(sp)
    80003e04:	6165                	addi	sp,sp,112
    80003e06:	8082                	ret
    return -1;
    80003e08:	557d                	li	a0,-1
}
    80003e0a:	8082                	ret
    return -1;
    80003e0c:	557d                	li	a0,-1
    80003e0e:	bff1                	j	80003dea <writei+0xf0>
    return -1;
    80003e10:	557d                	li	a0,-1
    80003e12:	bfe1                	j	80003dea <writei+0xf0>

0000000080003e14 <namecmp>:

// Directories

int
namecmp(const char *s, const char *t)
{
    80003e14:	1141                	addi	sp,sp,-16
    80003e16:	e406                	sd	ra,8(sp)
    80003e18:	e022                	sd	s0,0(sp)
    80003e1a:	0800                	addi	s0,sp,16
  return strncmp(s, t, DIRSIZ);
    80003e1c:	4639                	li	a2,14
    80003e1e:	ffffd097          	auipc	ra,0xffffd
    80003e22:	1a6080e7          	jalr	422(ra) # 80000fc4 <strncmp>
}
    80003e26:	60a2                	ld	ra,8(sp)
    80003e28:	6402                	ld	s0,0(sp)
    80003e2a:	0141                	addi	sp,sp,16
    80003e2c:	8082                	ret

0000000080003e2e <dirlookup>:

// Look for a directory entry in a directory.
// If found, set *poff to byte offset of entry.
struct inode*
dirlookup(struct inode *dp, char *name, uint *poff)
{
    80003e2e:	7139                	addi	sp,sp,-64
    80003e30:	fc06                	sd	ra,56(sp)
    80003e32:	f822                	sd	s0,48(sp)
    80003e34:	f426                	sd	s1,40(sp)
    80003e36:	f04a                	sd	s2,32(sp)
    80003e38:	ec4e                	sd	s3,24(sp)
    80003e3a:	e852                	sd	s4,16(sp)
    80003e3c:	0080                	addi	s0,sp,64
  uint off, inum;
  struct dirent de;

  if(dp->type != T_DIR)
    80003e3e:	04c51703          	lh	a4,76(a0)
    80003e42:	4785                	li	a5,1
    80003e44:	00f71a63          	bne	a4,a5,80003e58 <dirlookup+0x2a>
    80003e48:	892a                	mv	s2,a0
    80003e4a:	89ae                	mv	s3,a1
    80003e4c:	8a32                	mv	s4,a2
    panic("dirlookup not DIR");

  for(off = 0; off < dp->size; off += sizeof(de)){
    80003e4e:	497c                	lw	a5,84(a0)
    80003e50:	4481                	li	s1,0
      inum = de.inum;
      return iget(dp->dev, inum);
    }
  }

  return 0;
    80003e52:	4501                	li	a0,0
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003e54:	e79d                	bnez	a5,80003e82 <dirlookup+0x54>
    80003e56:	a8a5                	j	80003ece <dirlookup+0xa0>
    panic("dirlookup not DIR");
    80003e58:	00005517          	auipc	a0,0x5
    80003e5c:	8c050513          	addi	a0,a0,-1856 # 80008718 <userret+0x688>
    80003e60:	ffffc097          	auipc	ra,0xffffc
    80003e64:	71e080e7          	jalr	1822(ra) # 8000057e <panic>
      panic("dirlookup read");
    80003e68:	00005517          	auipc	a0,0x5
    80003e6c:	8c850513          	addi	a0,a0,-1848 # 80008730 <userret+0x6a0>
    80003e70:	ffffc097          	auipc	ra,0xffffc
    80003e74:	70e080e7          	jalr	1806(ra) # 8000057e <panic>
  for(off = 0; off < dp->size; off += sizeof(de)){
    80003e78:	24c1                	addiw	s1,s1,16
    80003e7a:	05492783          	lw	a5,84(s2)
    80003e7e:	04f4f763          	bleu	a5,s1,80003ecc <dirlookup+0x9e>
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80003e82:	4741                	li	a4,16
    80003e84:	86a6                	mv	a3,s1
    80003e86:	fc040613          	addi	a2,s0,-64
    80003e8a:	4581                	li	a1,0
    80003e8c:	854a                	mv	a0,s2
    80003e8e:	00000097          	auipc	ra,0x0
    80003e92:	d78080e7          	jalr	-648(ra) # 80003c06 <readi>
    80003e96:	47c1                	li	a5,16
    80003e98:	fcf518e3          	bne	a0,a5,80003e68 <dirlookup+0x3a>
    if(de.inum == 0)
    80003e9c:	fc045783          	lhu	a5,-64(s0)
    80003ea0:	dfe1                	beqz	a5,80003e78 <dirlookup+0x4a>
    if(namecmp(name, de.name) == 0){
    80003ea2:	fc240593          	addi	a1,s0,-62
    80003ea6:	854e                	mv	a0,s3
    80003ea8:	00000097          	auipc	ra,0x0
    80003eac:	f6c080e7          	jalr	-148(ra) # 80003e14 <namecmp>
    80003eb0:	f561                	bnez	a0,80003e78 <dirlookup+0x4a>
      if(poff)
    80003eb2:	000a0463          	beqz	s4,80003eba <dirlookup+0x8c>
        *poff = off;
    80003eb6:	009a2023          	sw	s1,0(s4) # 2000 <_entry-0x7fffe000>
      return iget(dp->dev, inum);
    80003eba:	fc045583          	lhu	a1,-64(s0)
    80003ebe:	00092503          	lw	a0,0(s2)
    80003ec2:	fffff097          	auipc	ra,0xfffff
    80003ec6:	77c080e7          	jalr	1916(ra) # 8000363e <iget>
    80003eca:	a011                	j	80003ece <dirlookup+0xa0>
  return 0;
    80003ecc:	4501                	li	a0,0
}
    80003ece:	70e2                	ld	ra,56(sp)
    80003ed0:	7442                	ld	s0,48(sp)
    80003ed2:	74a2                	ld	s1,40(sp)
    80003ed4:	7902                	ld	s2,32(sp)
    80003ed6:	69e2                	ld	s3,24(sp)
    80003ed8:	6a42                	ld	s4,16(sp)
    80003eda:	6121                	addi	sp,sp,64
    80003edc:	8082                	ret

0000000080003ede <namex>:
// If parent != 0, return the inode for the parent and copy the final
// path element into name, which must have room for DIRSIZ bytes.
// Must be called inside a transaction since it calls iput().
static struct inode*
namex(char *path, int nameiparent, char *name)
{
    80003ede:	711d                	addi	sp,sp,-96
    80003ee0:	ec86                	sd	ra,88(sp)
    80003ee2:	e8a2                	sd	s0,80(sp)
    80003ee4:	e4a6                	sd	s1,72(sp)
    80003ee6:	e0ca                	sd	s2,64(sp)
    80003ee8:	fc4e                	sd	s3,56(sp)
    80003eea:	f852                	sd	s4,48(sp)
    80003eec:	f456                	sd	s5,40(sp)
    80003eee:	f05a                	sd	s6,32(sp)
    80003ef0:	ec5e                	sd	s7,24(sp)
    80003ef2:	e862                	sd	s8,16(sp)
    80003ef4:	e466                	sd	s9,8(sp)
    80003ef6:	1080                	addi	s0,sp,96
    80003ef8:	84aa                	mv	s1,a0
    80003efa:	8bae                	mv	s7,a1
    80003efc:	8ab2                	mv	s5,a2
  struct inode *ip, *next;

  if(*path == '/')
    80003efe:	00054703          	lbu	a4,0(a0)
    80003f02:	02f00793          	li	a5,47
    80003f06:	02f70363          	beq	a4,a5,80003f2c <namex+0x4e>
    ip = iget(ROOTDEV, ROOTINO);
  else
    ip = idup(myproc()->cwd);
    80003f0a:	ffffe097          	auipc	ra,0xffffe
    80003f0e:	cfc080e7          	jalr	-772(ra) # 80001c06 <myproc>
    80003f12:	15853503          	ld	a0,344(a0)
    80003f16:	00000097          	auipc	ra,0x0
    80003f1a:	a20080e7          	jalr	-1504(ra) # 80003936 <idup>
    80003f1e:	89aa                	mv	s3,a0
  while(*path == '/')
    80003f20:	02f00913          	li	s2,47
  len = path - s;
    80003f24:	4b01                	li	s6,0
  if(len >= DIRSIZ)
    80003f26:	4cb5                	li	s9,13

  while((path = skipelem(path, name)) != 0){
    ilock(ip);
    if(ip->type != T_DIR){
    80003f28:	4c05                	li	s8,1
    80003f2a:	a865                	j	80003fe2 <namex+0x104>
    ip = iget(ROOTDEV, ROOTINO);
    80003f2c:	4585                	li	a1,1
    80003f2e:	4501                	li	a0,0
    80003f30:	fffff097          	auipc	ra,0xfffff
    80003f34:	70e080e7          	jalr	1806(ra) # 8000363e <iget>
    80003f38:	89aa                	mv	s3,a0
    80003f3a:	b7dd                	j	80003f20 <namex+0x42>
      iunlockput(ip);
    80003f3c:	854e                	mv	a0,s3
    80003f3e:	00000097          	auipc	ra,0x0
    80003f42:	c76080e7          	jalr	-906(ra) # 80003bb4 <iunlockput>
      return 0;
    80003f46:	4981                	li	s3,0
  if(nameiparent){
    iput(ip);
    return 0;
  }
  return ip;
}
    80003f48:	854e                	mv	a0,s3
    80003f4a:	60e6                	ld	ra,88(sp)
    80003f4c:	6446                	ld	s0,80(sp)
    80003f4e:	64a6                	ld	s1,72(sp)
    80003f50:	6906                	ld	s2,64(sp)
    80003f52:	79e2                	ld	s3,56(sp)
    80003f54:	7a42                	ld	s4,48(sp)
    80003f56:	7aa2                	ld	s5,40(sp)
    80003f58:	7b02                	ld	s6,32(sp)
    80003f5a:	6be2                	ld	s7,24(sp)
    80003f5c:	6c42                	ld	s8,16(sp)
    80003f5e:	6ca2                	ld	s9,8(sp)
    80003f60:	6125                	addi	sp,sp,96
    80003f62:	8082                	ret
      iunlock(ip);
    80003f64:	854e                	mv	a0,s3
    80003f66:	00000097          	auipc	ra,0x0
    80003f6a:	ad2080e7          	jalr	-1326(ra) # 80003a38 <iunlock>
      return ip;
    80003f6e:	bfe9                	j	80003f48 <namex+0x6a>
      iunlockput(ip);
    80003f70:	854e                	mv	a0,s3
    80003f72:	00000097          	auipc	ra,0x0
    80003f76:	c42080e7          	jalr	-958(ra) # 80003bb4 <iunlockput>
      return 0;
    80003f7a:	89d2                	mv	s3,s4
    80003f7c:	b7f1                	j	80003f48 <namex+0x6a>
  len = path - s;
    80003f7e:	40b48633          	sub	a2,s1,a1
    80003f82:	00060a1b          	sext.w	s4,a2
  if(len >= DIRSIZ)
    80003f86:	094cd663          	ble	s4,s9,80004012 <namex+0x134>
    memmove(name, s, DIRSIZ);
    80003f8a:	4639                	li	a2,14
    80003f8c:	8556                	mv	a0,s5
    80003f8e:	ffffd097          	auipc	ra,0xffffd
    80003f92:	fba080e7          	jalr	-70(ra) # 80000f48 <memmove>
  while(*path == '/')
    80003f96:	0004c783          	lbu	a5,0(s1)
    80003f9a:	01279763          	bne	a5,s2,80003fa8 <namex+0xca>
    path++;
    80003f9e:	0485                	addi	s1,s1,1
  while(*path == '/')
    80003fa0:	0004c783          	lbu	a5,0(s1)
    80003fa4:	ff278de3          	beq	a5,s2,80003f9e <namex+0xc0>
    ilock(ip);
    80003fa8:	854e                	mv	a0,s3
    80003faa:	00000097          	auipc	ra,0x0
    80003fae:	9ca080e7          	jalr	-1590(ra) # 80003974 <ilock>
    if(ip->type != T_DIR){
    80003fb2:	04c99783          	lh	a5,76(s3)
    80003fb6:	f98793e3          	bne	a5,s8,80003f3c <namex+0x5e>
    if(nameiparent && *path == '\0'){
    80003fba:	000b8563          	beqz	s7,80003fc4 <namex+0xe6>
    80003fbe:	0004c783          	lbu	a5,0(s1)
    80003fc2:	d3cd                	beqz	a5,80003f64 <namex+0x86>
    if((next = dirlookup(ip, name, 0)) == 0){
    80003fc4:	865a                	mv	a2,s6
    80003fc6:	85d6                	mv	a1,s5
    80003fc8:	854e                	mv	a0,s3
    80003fca:	00000097          	auipc	ra,0x0
    80003fce:	e64080e7          	jalr	-412(ra) # 80003e2e <dirlookup>
    80003fd2:	8a2a                	mv	s4,a0
    80003fd4:	dd51                	beqz	a0,80003f70 <namex+0x92>
    iunlockput(ip);
    80003fd6:	854e                	mv	a0,s3
    80003fd8:	00000097          	auipc	ra,0x0
    80003fdc:	bdc080e7          	jalr	-1060(ra) # 80003bb4 <iunlockput>
    ip = next;
    80003fe0:	89d2                	mv	s3,s4
  while(*path == '/')
    80003fe2:	0004c783          	lbu	a5,0(s1)
    80003fe6:	05279d63          	bne	a5,s2,80004040 <namex+0x162>
    path++;
    80003fea:	0485                	addi	s1,s1,1
  while(*path == '/')
    80003fec:	0004c783          	lbu	a5,0(s1)
    80003ff0:	ff278de3          	beq	a5,s2,80003fea <namex+0x10c>
  if(*path == 0)
    80003ff4:	cf8d                	beqz	a5,8000402e <namex+0x150>
  while(*path != '/' && *path != 0)
    80003ff6:	01278b63          	beq	a5,s2,8000400c <namex+0x12e>
    80003ffa:	c795                	beqz	a5,80004026 <namex+0x148>
    path++;
    80003ffc:	85a6                	mv	a1,s1
    path++;
    80003ffe:	0485                	addi	s1,s1,1
  while(*path != '/' && *path != 0)
    80004000:	0004c783          	lbu	a5,0(s1)
    80004004:	f7278de3          	beq	a5,s2,80003f7e <namex+0xa0>
    80004008:	fbfd                	bnez	a5,80003ffe <namex+0x120>
    8000400a:	bf95                	j	80003f7e <namex+0xa0>
    8000400c:	85a6                	mv	a1,s1
  len = path - s;
    8000400e:	8a5a                	mv	s4,s6
    80004010:	865a                	mv	a2,s6
    memmove(name, s, len);
    80004012:	2601                	sext.w	a2,a2
    80004014:	8556                	mv	a0,s5
    80004016:	ffffd097          	auipc	ra,0xffffd
    8000401a:	f32080e7          	jalr	-206(ra) # 80000f48 <memmove>
    name[len] = 0;
    8000401e:	9a56                	add	s4,s4,s5
    80004020:	000a0023          	sb	zero,0(s4)
    80004024:	bf8d                	j	80003f96 <namex+0xb8>
  while(*path != '/' && *path != 0)
    80004026:	85a6                	mv	a1,s1
  len = path - s;
    80004028:	8a5a                	mv	s4,s6
    8000402a:	865a                	mv	a2,s6
    8000402c:	b7dd                	j	80004012 <namex+0x134>
  if(nameiparent){
    8000402e:	f00b8de3          	beqz	s7,80003f48 <namex+0x6a>
    iput(ip);
    80004032:	854e                	mv	a0,s3
    80004034:	00000097          	auipc	ra,0x0
    80004038:	a50080e7          	jalr	-1456(ra) # 80003a84 <iput>
    return 0;
    8000403c:	4981                	li	s3,0
    8000403e:	b729                	j	80003f48 <namex+0x6a>
  if(*path == 0)
    80004040:	d7fd                	beqz	a5,8000402e <namex+0x150>
    80004042:	85a6                	mv	a1,s1
    80004044:	bf6d                	j	80003ffe <namex+0x120>

0000000080004046 <dirlink>:
{
    80004046:	7139                	addi	sp,sp,-64
    80004048:	fc06                	sd	ra,56(sp)
    8000404a:	f822                	sd	s0,48(sp)
    8000404c:	f426                	sd	s1,40(sp)
    8000404e:	f04a                	sd	s2,32(sp)
    80004050:	ec4e                	sd	s3,24(sp)
    80004052:	e852                	sd	s4,16(sp)
    80004054:	0080                	addi	s0,sp,64
    80004056:	892a                	mv	s2,a0
    80004058:	8a2e                	mv	s4,a1
    8000405a:	89b2                	mv	s3,a2
  if((ip = dirlookup(dp, name, 0)) != 0){
    8000405c:	4601                	li	a2,0
    8000405e:	00000097          	auipc	ra,0x0
    80004062:	dd0080e7          	jalr	-560(ra) # 80003e2e <dirlookup>
    80004066:	e93d                	bnez	a0,800040dc <dirlink+0x96>
  for(off = 0; off < dp->size; off += sizeof(de)){
    80004068:	05492483          	lw	s1,84(s2)
    8000406c:	c49d                	beqz	s1,8000409a <dirlink+0x54>
    8000406e:	4481                	li	s1,0
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    80004070:	4741                	li	a4,16
    80004072:	86a6                	mv	a3,s1
    80004074:	fc040613          	addi	a2,s0,-64
    80004078:	4581                	li	a1,0
    8000407a:	854a                	mv	a0,s2
    8000407c:	00000097          	auipc	ra,0x0
    80004080:	b8a080e7          	jalr	-1142(ra) # 80003c06 <readi>
    80004084:	47c1                	li	a5,16
    80004086:	06f51163          	bne	a0,a5,800040e8 <dirlink+0xa2>
    if(de.inum == 0)
    8000408a:	fc045783          	lhu	a5,-64(s0)
    8000408e:	c791                	beqz	a5,8000409a <dirlink+0x54>
  for(off = 0; off < dp->size; off += sizeof(de)){
    80004090:	24c1                	addiw	s1,s1,16
    80004092:	05492783          	lw	a5,84(s2)
    80004096:	fcf4ede3          	bltu	s1,a5,80004070 <dirlink+0x2a>
  strncpy(de.name, name, DIRSIZ);
    8000409a:	4639                	li	a2,14
    8000409c:	85d2                	mv	a1,s4
    8000409e:	fc240513          	addi	a0,s0,-62
    800040a2:	ffffd097          	auipc	ra,0xffffd
    800040a6:	f72080e7          	jalr	-142(ra) # 80001014 <strncpy>
  de.inum = inum;
    800040aa:	fd341023          	sh	s3,-64(s0)
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    800040ae:	4741                	li	a4,16
    800040b0:	86a6                	mv	a3,s1
    800040b2:	fc040613          	addi	a2,s0,-64
    800040b6:	4581                	li	a1,0
    800040b8:	854a                	mv	a0,s2
    800040ba:	00000097          	auipc	ra,0x0
    800040be:	c40080e7          	jalr	-960(ra) # 80003cfa <writei>
    800040c2:	4741                	li	a4,16
  return 0;
    800040c4:	4781                	li	a5,0
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    800040c6:	02e51963          	bne	a0,a4,800040f8 <dirlink+0xb2>
}
    800040ca:	853e                	mv	a0,a5
    800040cc:	70e2                	ld	ra,56(sp)
    800040ce:	7442                	ld	s0,48(sp)
    800040d0:	74a2                	ld	s1,40(sp)
    800040d2:	7902                	ld	s2,32(sp)
    800040d4:	69e2                	ld	s3,24(sp)
    800040d6:	6a42                	ld	s4,16(sp)
    800040d8:	6121                	addi	sp,sp,64
    800040da:	8082                	ret
    iput(ip);
    800040dc:	00000097          	auipc	ra,0x0
    800040e0:	9a8080e7          	jalr	-1624(ra) # 80003a84 <iput>
    return -1;
    800040e4:	57fd                	li	a5,-1
    800040e6:	b7d5                	j	800040ca <dirlink+0x84>
      panic("dirlink read");
    800040e8:	00004517          	auipc	a0,0x4
    800040ec:	65850513          	addi	a0,a0,1624 # 80008740 <userret+0x6b0>
    800040f0:	ffffc097          	auipc	ra,0xffffc
    800040f4:	48e080e7          	jalr	1166(ra) # 8000057e <panic>
    panic("dirlink");
    800040f8:	00004517          	auipc	a0,0x4
    800040fc:	76850513          	addi	a0,a0,1896 # 80008860 <userret+0x7d0>
    80004100:	ffffc097          	auipc	ra,0xffffc
    80004104:	47e080e7          	jalr	1150(ra) # 8000057e <panic>

0000000080004108 <namei>:

struct inode*
namei(char *path)
{
    80004108:	1101                	addi	sp,sp,-32
    8000410a:	ec06                	sd	ra,24(sp)
    8000410c:	e822                	sd	s0,16(sp)
    8000410e:	1000                	addi	s0,sp,32
  char name[DIRSIZ];
  return namex(path, 0, name);
    80004110:	fe040613          	addi	a2,s0,-32
    80004114:	4581                	li	a1,0
    80004116:	00000097          	auipc	ra,0x0
    8000411a:	dc8080e7          	jalr	-568(ra) # 80003ede <namex>
}
    8000411e:	60e2                	ld	ra,24(sp)
    80004120:	6442                	ld	s0,16(sp)
    80004122:	6105                	addi	sp,sp,32
    80004124:	8082                	ret

0000000080004126 <nameiparent>:

struct inode*
nameiparent(char *path, char *name)
{
    80004126:	1141                	addi	sp,sp,-16
    80004128:	e406                	sd	ra,8(sp)
    8000412a:	e022                	sd	s0,0(sp)
    8000412c:	0800                	addi	s0,sp,16
  return namex(path, 1, name);
    8000412e:	862e                	mv	a2,a1
    80004130:	4585                	li	a1,1
    80004132:	00000097          	auipc	ra,0x0
    80004136:	dac080e7          	jalr	-596(ra) # 80003ede <namex>
}
    8000413a:	60a2                	ld	ra,8(sp)
    8000413c:	6402                	ld	s0,0(sp)
    8000413e:	0141                	addi	sp,sp,16
    80004140:	8082                	ret

0000000080004142 <write_head>:
// Write in-memory log header to disk.
// This is the true point at which the
// current transaction commits.
static void
write_head(int dev)
{
    80004142:	7179                	addi	sp,sp,-48
    80004144:	f406                	sd	ra,40(sp)
    80004146:	f022                	sd	s0,32(sp)
    80004148:	ec26                	sd	s1,24(sp)
    8000414a:	e84a                	sd	s2,16(sp)
    8000414c:	e44e                	sd	s3,8(sp)
    8000414e:	1800                	addi	s0,sp,48
    80004150:	84aa                	mv	s1,a0
  struct buf *buf = bread(dev, log[dev].start);
    80004152:	0b000993          	li	s3,176
    80004156:	033507b3          	mul	a5,a0,s3
    8000415a:	00024997          	auipc	s3,0x24
    8000415e:	3d698993          	addi	s3,s3,982 # 80028530 <log>
    80004162:	99be                	add	s3,s3,a5
    80004164:	0209a583          	lw	a1,32(s3)
    80004168:	fffff097          	auipc	ra,0xfffff
    8000416c:	eba080e7          	jalr	-326(ra) # 80003022 <bread>
    80004170:	892a                	mv	s2,a0
  struct logheader *hb = (struct logheader *) (buf->data);
  int i;
  hb->n = log[dev].lh.n;
    80004172:	0349a783          	lw	a5,52(s3)
    80004176:	d17c                	sw	a5,100(a0)
  for (i = 0; i < log[dev].lh.n; i++) {
    80004178:	0349a783          	lw	a5,52(s3)
    8000417c:	02f05763          	blez	a5,800041aa <write_head+0x68>
    80004180:	0b000793          	li	a5,176
    80004184:	02f487b3          	mul	a5,s1,a5
    80004188:	00024717          	auipc	a4,0x24
    8000418c:	3e070713          	addi	a4,a4,992 # 80028568 <log+0x38>
    80004190:	97ba                	add	a5,a5,a4
    80004192:	06850693          	addi	a3,a0,104
    80004196:	4701                	li	a4,0
    80004198:	85ce                	mv	a1,s3
    hb->block[i] = log[dev].lh.block[i];
    8000419a:	4390                	lw	a2,0(a5)
    8000419c:	c290                	sw	a2,0(a3)
  for (i = 0; i < log[dev].lh.n; i++) {
    8000419e:	2705                	addiw	a4,a4,1
    800041a0:	0791                	addi	a5,a5,4
    800041a2:	0691                	addi	a3,a3,4
    800041a4:	59d0                	lw	a2,52(a1)
    800041a6:	fec74ae3          	blt	a4,a2,8000419a <write_head+0x58>
  }
  bwrite(buf);
    800041aa:	854a                	mv	a0,s2
    800041ac:	fffff097          	auipc	ra,0xfffff
    800041b0:	0ca080e7          	jalr	202(ra) # 80003276 <bwrite>
  brelse(buf);
    800041b4:	854a                	mv	a0,s2
    800041b6:	fffff097          	auipc	ra,0xfffff
    800041ba:	100080e7          	jalr	256(ra) # 800032b6 <brelse>
}
    800041be:	70a2                	ld	ra,40(sp)
    800041c0:	7402                	ld	s0,32(sp)
    800041c2:	64e2                	ld	s1,24(sp)
    800041c4:	6942                	ld	s2,16(sp)
    800041c6:	69a2                	ld	s3,8(sp)
    800041c8:	6145                	addi	sp,sp,48
    800041ca:	8082                	ret

00000000800041cc <install_trans>:
  for (tail = 0; tail < log[dev].lh.n; tail++) {
    800041cc:	0b000793          	li	a5,176
    800041d0:	02f50733          	mul	a4,a0,a5
    800041d4:	00024797          	auipc	a5,0x24
    800041d8:	35c78793          	addi	a5,a5,860 # 80028530 <log>
    800041dc:	97ba                	add	a5,a5,a4
    800041de:	5bdc                	lw	a5,52(a5)
    800041e0:	0af05b63          	blez	a5,80004296 <install_trans+0xca>
{
    800041e4:	7139                	addi	sp,sp,-64
    800041e6:	fc06                	sd	ra,56(sp)
    800041e8:	f822                	sd	s0,48(sp)
    800041ea:	f426                	sd	s1,40(sp)
    800041ec:	f04a                	sd	s2,32(sp)
    800041ee:	ec4e                	sd	s3,24(sp)
    800041f0:	e852                	sd	s4,16(sp)
    800041f2:	e456                	sd	s5,8(sp)
    800041f4:	e05a                	sd	s6,0(sp)
    800041f6:	0080                	addi	s0,sp,64
    800041f8:	00024797          	auipc	a5,0x24
    800041fc:	37078793          	addi	a5,a5,880 # 80028568 <log+0x38>
    80004200:	00f709b3          	add	s3,a4,a5
  for (tail = 0; tail < log[dev].lh.n; tail++) {
    80004204:	4901                	li	s2,0
    struct buf *lbuf = bread(dev, log[dev].start+tail+1); // read log block
    80004206:	00050b1b          	sext.w	s6,a0
    8000420a:	00024a97          	auipc	s5,0x24
    8000420e:	326a8a93          	addi	s5,s5,806 # 80028530 <log>
    80004212:	9aba                	add	s5,s5,a4
    80004214:	020aa583          	lw	a1,32(s5)
    80004218:	012585bb          	addw	a1,a1,s2
    8000421c:	2585                	addiw	a1,a1,1
    8000421e:	855a                	mv	a0,s6
    80004220:	fffff097          	auipc	ra,0xfffff
    80004224:	e02080e7          	jalr	-510(ra) # 80003022 <bread>
    80004228:	8a2a                	mv	s4,a0
    struct buf *dbuf = bread(dev, log[dev].lh.block[tail]); // read dst
    8000422a:	0009a583          	lw	a1,0(s3)
    8000422e:	855a                	mv	a0,s6
    80004230:	fffff097          	auipc	ra,0xfffff
    80004234:	df2080e7          	jalr	-526(ra) # 80003022 <bread>
    80004238:	84aa                	mv	s1,a0
    memmove(dbuf->data, lbuf->data, BSIZE);  // copy block to dst
    8000423a:	40000613          	li	a2,1024
    8000423e:	064a0593          	addi	a1,s4,100
    80004242:	06450513          	addi	a0,a0,100
    80004246:	ffffd097          	auipc	ra,0xffffd
    8000424a:	d02080e7          	jalr	-766(ra) # 80000f48 <memmove>
    bwrite(dbuf);  // write dst to disk
    8000424e:	8526                	mv	a0,s1
    80004250:	fffff097          	auipc	ra,0xfffff
    80004254:	026080e7          	jalr	38(ra) # 80003276 <bwrite>
    bunpin(dbuf);
    80004258:	8526                	mv	a0,s1
    8000425a:	fffff097          	auipc	ra,0xfffff
    8000425e:	0ee080e7          	jalr	238(ra) # 80003348 <bunpin>
    brelse(lbuf);
    80004262:	8552                	mv	a0,s4
    80004264:	fffff097          	auipc	ra,0xfffff
    80004268:	052080e7          	jalr	82(ra) # 800032b6 <brelse>
    brelse(dbuf);
    8000426c:	8526                	mv	a0,s1
    8000426e:	fffff097          	auipc	ra,0xfffff
    80004272:	048080e7          	jalr	72(ra) # 800032b6 <brelse>
  for (tail = 0; tail < log[dev].lh.n; tail++) {
    80004276:	2905                	addiw	s2,s2,1
    80004278:	0991                	addi	s3,s3,4
    8000427a:	034aa783          	lw	a5,52(s5)
    8000427e:	f8f94be3          	blt	s2,a5,80004214 <install_trans+0x48>
}
    80004282:	70e2                	ld	ra,56(sp)
    80004284:	7442                	ld	s0,48(sp)
    80004286:	74a2                	ld	s1,40(sp)
    80004288:	7902                	ld	s2,32(sp)
    8000428a:	69e2                	ld	s3,24(sp)
    8000428c:	6a42                	ld	s4,16(sp)
    8000428e:	6aa2                	ld	s5,8(sp)
    80004290:	6b02                	ld	s6,0(sp)
    80004292:	6121                	addi	sp,sp,64
    80004294:	8082                	ret
    80004296:	8082                	ret

0000000080004298 <initlog>:
{
    80004298:	7179                	addi	sp,sp,-48
    8000429a:	f406                	sd	ra,40(sp)
    8000429c:	f022                	sd	s0,32(sp)
    8000429e:	ec26                	sd	s1,24(sp)
    800042a0:	e84a                	sd	s2,16(sp)
    800042a2:	e44e                	sd	s3,8(sp)
    800042a4:	e052                	sd	s4,0(sp)
    800042a6:	1800                	addi	s0,sp,48
    800042a8:	89aa                	mv	s3,a0
    800042aa:	8a2e                	mv	s4,a1
  initlock(&log[dev].lock, "log");
    800042ac:	0b000713          	li	a4,176
    800042b0:	02e504b3          	mul	s1,a0,a4
    800042b4:	00024917          	auipc	s2,0x24
    800042b8:	27c90913          	addi	s2,s2,636 # 80028530 <log>
    800042bc:	9926                	add	s2,s2,s1
    800042be:	00004597          	auipc	a1,0x4
    800042c2:	49258593          	addi	a1,a1,1170 # 80008750 <userret+0x6c0>
    800042c6:	854a                	mv	a0,s2
    800042c8:	ffffd097          	auipc	ra,0xffffd
    800042cc:	82e080e7          	jalr	-2002(ra) # 80000af6 <initlock>
  log[dev].start = sb->logstart;
    800042d0:	014a2583          	lw	a1,20(s4)
    800042d4:	02b92023          	sw	a1,32(s2)
  log[dev].size = sb->nlog;
    800042d8:	010a2783          	lw	a5,16(s4)
    800042dc:	02f92223          	sw	a5,36(s2)
  log[dev].dev = dev;
    800042e0:	03392823          	sw	s3,48(s2)
  struct buf *buf = bread(dev, log[dev].start);
    800042e4:	854e                	mv	a0,s3
    800042e6:	fffff097          	auipc	ra,0xfffff
    800042ea:	d3c080e7          	jalr	-708(ra) # 80003022 <bread>
  log[dev].lh.n = lh->n;
    800042ee:	517c                	lw	a5,100(a0)
    800042f0:	02f92a23          	sw	a5,52(s2)
  for (i = 0; i < log[dev].lh.n; i++) {
    800042f4:	02f05663          	blez	a5,80004320 <initlog+0x88>
    800042f8:	06850693          	addi	a3,a0,104
    800042fc:	00024717          	auipc	a4,0x24
    80004300:	26c70713          	addi	a4,a4,620 # 80028568 <log+0x38>
    80004304:	9726                	add	a4,a4,s1
    80004306:	37fd                	addiw	a5,a5,-1
    80004308:	1782                	slli	a5,a5,0x20
    8000430a:	9381                	srli	a5,a5,0x20
    8000430c:	078a                	slli	a5,a5,0x2
    8000430e:	06c50613          	addi	a2,a0,108
    80004312:	97b2                	add	a5,a5,a2
    log[dev].lh.block[i] = lh->block[i];
    80004314:	4290                	lw	a2,0(a3)
    80004316:	c310                	sw	a2,0(a4)
  for (i = 0; i < log[dev].lh.n; i++) {
    80004318:	0691                	addi	a3,a3,4
    8000431a:	0711                	addi	a4,a4,4
    8000431c:	fef69ce3          	bne	a3,a5,80004314 <initlog+0x7c>
  brelse(buf);
    80004320:	fffff097          	auipc	ra,0xfffff
    80004324:	f96080e7          	jalr	-106(ra) # 800032b6 <brelse>

static void
recover_from_log(int dev)
{
  read_head(dev);
  install_trans(dev); // if committed, copy from log to disk
    80004328:	854e                	mv	a0,s3
    8000432a:	00000097          	auipc	ra,0x0
    8000432e:	ea2080e7          	jalr	-350(ra) # 800041cc <install_trans>
  log[dev].lh.n = 0;
    80004332:	0b000793          	li	a5,176
    80004336:	02f98733          	mul	a4,s3,a5
    8000433a:	00024797          	auipc	a5,0x24
    8000433e:	1f678793          	addi	a5,a5,502 # 80028530 <log>
    80004342:	97ba                	add	a5,a5,a4
    80004344:	0207aa23          	sw	zero,52(a5)
  write_head(dev); // clear the log
    80004348:	854e                	mv	a0,s3
    8000434a:	00000097          	auipc	ra,0x0
    8000434e:	df8080e7          	jalr	-520(ra) # 80004142 <write_head>
}
    80004352:	70a2                	ld	ra,40(sp)
    80004354:	7402                	ld	s0,32(sp)
    80004356:	64e2                	ld	s1,24(sp)
    80004358:	6942                	ld	s2,16(sp)
    8000435a:	69a2                	ld	s3,8(sp)
    8000435c:	6a02                	ld	s4,0(sp)
    8000435e:	6145                	addi	sp,sp,48
    80004360:	8082                	ret

0000000080004362 <begin_op>:
}

// called at the start of each FS system call.
void
begin_op(int dev)
{
    80004362:	7139                	addi	sp,sp,-64
    80004364:	fc06                	sd	ra,56(sp)
    80004366:	f822                	sd	s0,48(sp)
    80004368:	f426                	sd	s1,40(sp)
    8000436a:	f04a                	sd	s2,32(sp)
    8000436c:	ec4e                	sd	s3,24(sp)
    8000436e:	e852                	sd	s4,16(sp)
    80004370:	e456                	sd	s5,8(sp)
    80004372:	0080                	addi	s0,sp,64
    80004374:	8aaa                	mv	s5,a0
  acquire(&log[dev].lock);
    80004376:	0b000913          	li	s2,176
    8000437a:	032507b3          	mul	a5,a0,s2
    8000437e:	00024917          	auipc	s2,0x24
    80004382:	1b290913          	addi	s2,s2,434 # 80028530 <log>
    80004386:	993e                	add	s2,s2,a5
    80004388:	854a                	mv	a0,s2
    8000438a:	ffffd097          	auipc	ra,0xffffd
    8000438e:	8bc080e7          	jalr	-1860(ra) # 80000c46 <acquire>
  while(1){
    if(log[dev].committing){
    80004392:	00024997          	auipc	s3,0x24
    80004396:	19e98993          	addi	s3,s3,414 # 80028530 <log>
    8000439a:	84ca                	mv	s1,s2
      sleep(&log, &log[dev].lock);
    } else if(log[dev].lh.n + (log[dev].outstanding+1)*MAXOPBLOCKS > LOGSIZE){
    8000439c:	4a79                	li	s4,30
    8000439e:	a039                	j	800043ac <begin_op+0x4a>
      sleep(&log, &log[dev].lock);
    800043a0:	85ca                	mv	a1,s2
    800043a2:	854e                	mv	a0,s3
    800043a4:	ffffe097          	auipc	ra,0xffffe
    800043a8:	03e080e7          	jalr	62(ra) # 800023e2 <sleep>
    if(log[dev].committing){
    800043ac:	54dc                	lw	a5,44(s1)
    800043ae:	fbed                	bnez	a5,800043a0 <begin_op+0x3e>
    } else if(log[dev].lh.n + (log[dev].outstanding+1)*MAXOPBLOCKS > LOGSIZE){
    800043b0:	549c                	lw	a5,40(s1)
    800043b2:	0017871b          	addiw	a4,a5,1
    800043b6:	0007069b          	sext.w	a3,a4
    800043ba:	0027179b          	slliw	a5,a4,0x2
    800043be:	9fb9                	addw	a5,a5,a4
    800043c0:	0017979b          	slliw	a5,a5,0x1
    800043c4:	58d8                	lw	a4,52(s1)
    800043c6:	9fb9                	addw	a5,a5,a4
    800043c8:	00fa5963          	ble	a5,s4,800043da <begin_op+0x78>
      // this op might exhaust log space; wait for commit.
      sleep(&log, &log[dev].lock);
    800043cc:	85ca                	mv	a1,s2
    800043ce:	854e                	mv	a0,s3
    800043d0:	ffffe097          	auipc	ra,0xffffe
    800043d4:	012080e7          	jalr	18(ra) # 800023e2 <sleep>
    800043d8:	bfd1                	j	800043ac <begin_op+0x4a>
    } else {
      log[dev].outstanding += 1;
    800043da:	0b000793          	li	a5,176
    800043de:	02fa8ab3          	mul	s5,s5,a5
    800043e2:	00024797          	auipc	a5,0x24
    800043e6:	14e78793          	addi	a5,a5,334 # 80028530 <log>
    800043ea:	9abe                	add	s5,s5,a5
    800043ec:	02daa423          	sw	a3,40(s5)
      release(&log[dev].lock);
    800043f0:	854a                	mv	a0,s2
    800043f2:	ffffd097          	auipc	ra,0xffffd
    800043f6:	8c4080e7          	jalr	-1852(ra) # 80000cb6 <release>
      break;
    }
  }
}
    800043fa:	70e2                	ld	ra,56(sp)
    800043fc:	7442                	ld	s0,48(sp)
    800043fe:	74a2                	ld	s1,40(sp)
    80004400:	7902                	ld	s2,32(sp)
    80004402:	69e2                	ld	s3,24(sp)
    80004404:	6a42                	ld	s4,16(sp)
    80004406:	6aa2                	ld	s5,8(sp)
    80004408:	6121                	addi	sp,sp,64
    8000440a:	8082                	ret

000000008000440c <end_op>:

// called at the end of each FS system call.
// commits if this was the last outstanding operation.
void
end_op(int dev)
{
    8000440c:	715d                	addi	sp,sp,-80
    8000440e:	e486                	sd	ra,72(sp)
    80004410:	e0a2                	sd	s0,64(sp)
    80004412:	fc26                	sd	s1,56(sp)
    80004414:	f84a                	sd	s2,48(sp)
    80004416:	f44e                	sd	s3,40(sp)
    80004418:	f052                	sd	s4,32(sp)
    8000441a:	ec56                	sd	s5,24(sp)
    8000441c:	e85a                	sd	s6,16(sp)
    8000441e:	e45e                	sd	s7,8(sp)
    80004420:	e062                	sd	s8,0(sp)
    80004422:	0880                	addi	s0,sp,80
    80004424:	89aa                	mv	s3,a0
  int do_commit = 0;

  acquire(&log[dev].lock);
    80004426:	0b000a13          	li	s4,176
    8000442a:	03450a33          	mul	s4,a0,s4
    8000442e:	00024497          	auipc	s1,0x24
    80004432:	10248493          	addi	s1,s1,258 # 80028530 <log>
    80004436:	94d2                	add	s1,s1,s4
    80004438:	8526                	mv	a0,s1
    8000443a:	ffffd097          	auipc	ra,0xffffd
    8000443e:	80c080e7          	jalr	-2036(ra) # 80000c46 <acquire>
  log[dev].outstanding -= 1;
    80004442:	549c                	lw	a5,40(s1)
    80004444:	37fd                	addiw	a5,a5,-1
    80004446:	0007891b          	sext.w	s2,a5
    8000444a:	d49c                	sw	a5,40(s1)
  if(log[dev].committing)
    8000444c:	54dc                	lw	a5,44(s1)
    8000444e:	e3b5                	bnez	a5,800044b2 <end_op+0xa6>
    panic("log[dev].committing");
  if(log[dev].outstanding == 0){
    80004450:	06091963          	bnez	s2,800044c2 <end_op+0xb6>
    do_commit = 1;
    log[dev].committing = 1;
    80004454:	0b000a93          	li	s5,176
    80004458:	035987b3          	mul	a5,s3,s5
    8000445c:	00024a97          	auipc	s5,0x24
    80004460:	0d4a8a93          	addi	s5,s5,212 # 80028530 <log>
    80004464:	9abe                	add	s5,s5,a5
    80004466:	4785                	li	a5,1
    80004468:	02faa623          	sw	a5,44(s5)
    // begin_op() may be waiting for log space,
    // and decrementing log[dev].outstanding has decreased
    // the amount of reserved space.
    wakeup(&log);
  }
  release(&log[dev].lock);
    8000446c:	8526                	mv	a0,s1
    8000446e:	ffffd097          	auipc	ra,0xffffd
    80004472:	848080e7          	jalr	-1976(ra) # 80000cb6 <release>
}

static void
commit(int dev)
{
  if (log[dev].lh.n > 0) {
    80004476:	034aa783          	lw	a5,52(s5)
    8000447a:	06f04d63          	bgtz	a5,800044f4 <end_op+0xe8>
    acquire(&log[dev].lock);
    8000447e:	8526                	mv	a0,s1
    80004480:	ffffc097          	auipc	ra,0xffffc
    80004484:	7c6080e7          	jalr	1990(ra) # 80000c46 <acquire>
    log[dev].committing = 0;
    80004488:	00024517          	auipc	a0,0x24
    8000448c:	0a850513          	addi	a0,a0,168 # 80028530 <log>
    80004490:	0b000793          	li	a5,176
    80004494:	02f989b3          	mul	s3,s3,a5
    80004498:	99aa                	add	s3,s3,a0
    8000449a:	0209a623          	sw	zero,44(s3)
    wakeup(&log);
    8000449e:	ffffe097          	auipc	ra,0xffffe
    800044a2:	0ca080e7          	jalr	202(ra) # 80002568 <wakeup>
    release(&log[dev].lock);
    800044a6:	8526                	mv	a0,s1
    800044a8:	ffffd097          	auipc	ra,0xffffd
    800044ac:	80e080e7          	jalr	-2034(ra) # 80000cb6 <release>
}
    800044b0:	a035                	j	800044dc <end_op+0xd0>
    panic("log[dev].committing");
    800044b2:	00004517          	auipc	a0,0x4
    800044b6:	2a650513          	addi	a0,a0,678 # 80008758 <userret+0x6c8>
    800044ba:	ffffc097          	auipc	ra,0xffffc
    800044be:	0c4080e7          	jalr	196(ra) # 8000057e <panic>
    wakeup(&log);
    800044c2:	00024517          	auipc	a0,0x24
    800044c6:	06e50513          	addi	a0,a0,110 # 80028530 <log>
    800044ca:	ffffe097          	auipc	ra,0xffffe
    800044ce:	09e080e7          	jalr	158(ra) # 80002568 <wakeup>
  release(&log[dev].lock);
    800044d2:	8526                	mv	a0,s1
    800044d4:	ffffc097          	auipc	ra,0xffffc
    800044d8:	7e2080e7          	jalr	2018(ra) # 80000cb6 <release>
}
    800044dc:	60a6                	ld	ra,72(sp)
    800044de:	6406                	ld	s0,64(sp)
    800044e0:	74e2                	ld	s1,56(sp)
    800044e2:	7942                	ld	s2,48(sp)
    800044e4:	79a2                	ld	s3,40(sp)
    800044e6:	7a02                	ld	s4,32(sp)
    800044e8:	6ae2                	ld	s5,24(sp)
    800044ea:	6b42                	ld	s6,16(sp)
    800044ec:	6ba2                	ld	s7,8(sp)
    800044ee:	6c02                	ld	s8,0(sp)
    800044f0:	6161                	addi	sp,sp,80
    800044f2:	8082                	ret
    800044f4:	00024797          	auipc	a5,0x24
    800044f8:	07478793          	addi	a5,a5,116 # 80028568 <log+0x38>
    800044fc:	9a3e                	add	s4,s4,a5
    struct buf *to = bread(dev, log[dev].start+tail+1); // log block
    800044fe:	00098c1b          	sext.w	s8,s3
    80004502:	0b000b93          	li	s7,176
    80004506:	037987b3          	mul	a5,s3,s7
    8000450a:	00024b97          	auipc	s7,0x24
    8000450e:	026b8b93          	addi	s7,s7,38 # 80028530 <log>
    80004512:	9bbe                	add	s7,s7,a5
    80004514:	020ba583          	lw	a1,32(s7)
    80004518:	012585bb          	addw	a1,a1,s2
    8000451c:	2585                	addiw	a1,a1,1
    8000451e:	8562                	mv	a0,s8
    80004520:	fffff097          	auipc	ra,0xfffff
    80004524:	b02080e7          	jalr	-1278(ra) # 80003022 <bread>
    80004528:	8aaa                	mv	s5,a0
    struct buf *from = bread(dev, log[dev].lh.block[tail]); // cache block
    8000452a:	000a2583          	lw	a1,0(s4)
    8000452e:	8562                	mv	a0,s8
    80004530:	fffff097          	auipc	ra,0xfffff
    80004534:	af2080e7          	jalr	-1294(ra) # 80003022 <bread>
    80004538:	8b2a                	mv	s6,a0
    memmove(to->data, from->data, BSIZE);
    8000453a:	40000613          	li	a2,1024
    8000453e:	06450593          	addi	a1,a0,100
    80004542:	064a8513          	addi	a0,s5,100
    80004546:	ffffd097          	auipc	ra,0xffffd
    8000454a:	a02080e7          	jalr	-1534(ra) # 80000f48 <memmove>
    bwrite(to);  // write the log
    8000454e:	8556                	mv	a0,s5
    80004550:	fffff097          	auipc	ra,0xfffff
    80004554:	d26080e7          	jalr	-730(ra) # 80003276 <bwrite>
    brelse(from);
    80004558:	855a                	mv	a0,s6
    8000455a:	fffff097          	auipc	ra,0xfffff
    8000455e:	d5c080e7          	jalr	-676(ra) # 800032b6 <brelse>
    brelse(to);
    80004562:	8556                	mv	a0,s5
    80004564:	fffff097          	auipc	ra,0xfffff
    80004568:	d52080e7          	jalr	-686(ra) # 800032b6 <brelse>
  for (tail = 0; tail < log[dev].lh.n; tail++) {
    8000456c:	2905                	addiw	s2,s2,1
    8000456e:	0a11                	addi	s4,s4,4
    80004570:	034ba783          	lw	a5,52(s7)
    80004574:	faf940e3          	blt	s2,a5,80004514 <end_op+0x108>
    write_log(dev);     // Write modified blocks from cache to log
    write_head(dev);    // Write header to disk -- the real commit
    80004578:	854e                	mv	a0,s3
    8000457a:	00000097          	auipc	ra,0x0
    8000457e:	bc8080e7          	jalr	-1080(ra) # 80004142 <write_head>
    install_trans(dev); // Now install writes to home locations
    80004582:	854e                	mv	a0,s3
    80004584:	00000097          	auipc	ra,0x0
    80004588:	c48080e7          	jalr	-952(ra) # 800041cc <install_trans>
    log[dev].lh.n = 0;
    8000458c:	0b000793          	li	a5,176
    80004590:	02f98733          	mul	a4,s3,a5
    80004594:	00024797          	auipc	a5,0x24
    80004598:	f9c78793          	addi	a5,a5,-100 # 80028530 <log>
    8000459c:	97ba                	add	a5,a5,a4
    8000459e:	0207aa23          	sw	zero,52(a5)
    write_head(dev);    // Erase the transaction from the log
    800045a2:	854e                	mv	a0,s3
    800045a4:	00000097          	auipc	ra,0x0
    800045a8:	b9e080e7          	jalr	-1122(ra) # 80004142 <write_head>
    800045ac:	bdc9                	j	8000447e <end_op+0x72>

00000000800045ae <log_write>:
//   modify bp->data[]
//   log_write(bp)
//   brelse(bp)
void
log_write(struct buf *b)
{
    800045ae:	7179                	addi	sp,sp,-48
    800045b0:	f406                	sd	ra,40(sp)
    800045b2:	f022                	sd	s0,32(sp)
    800045b4:	ec26                	sd	s1,24(sp)
    800045b6:	e84a                	sd	s2,16(sp)
    800045b8:	e44e                	sd	s3,8(sp)
    800045ba:	e052                	sd	s4,0(sp)
    800045bc:	1800                	addi	s0,sp,48
  int i;

  int dev = b->dev;
    800045be:	00852903          	lw	s2,8(a0)
  if (log[dev].lh.n >= LOGSIZE || log[dev].lh.n >= log[dev].size - 1)
    800045c2:	0b000793          	li	a5,176
    800045c6:	02f90733          	mul	a4,s2,a5
    800045ca:	00024797          	auipc	a5,0x24
    800045ce:	f6678793          	addi	a5,a5,-154 # 80028530 <log>
    800045d2:	97ba                	add	a5,a5,a4
    800045d4:	5bd4                	lw	a3,52(a5)
    800045d6:	47f5                	li	a5,29
    800045d8:	0ad7c763          	blt	a5,a3,80004686 <log_write+0xd8>
    800045dc:	8a2a                	mv	s4,a0
    800045de:	00024797          	auipc	a5,0x24
    800045e2:	f5278793          	addi	a5,a5,-174 # 80028530 <log>
    800045e6:	97ba                	add	a5,a5,a4
    800045e8:	53dc                	lw	a5,36(a5)
    800045ea:	37fd                	addiw	a5,a5,-1
    800045ec:	08f6dd63          	ble	a5,a3,80004686 <log_write+0xd8>
    panic("too big a transaction");
  if (log[dev].outstanding < 1)
    800045f0:	0b000793          	li	a5,176
    800045f4:	02f90733          	mul	a4,s2,a5
    800045f8:	00024797          	auipc	a5,0x24
    800045fc:	f3878793          	addi	a5,a5,-200 # 80028530 <log>
    80004600:	97ba                	add	a5,a5,a4
    80004602:	579c                	lw	a5,40(a5)
    80004604:	08f05963          	blez	a5,80004696 <log_write+0xe8>
    panic("log_write outside of trans");

  acquire(&log[dev].lock);
    80004608:	0b000793          	li	a5,176
    8000460c:	02f904b3          	mul	s1,s2,a5
    80004610:	00024997          	auipc	s3,0x24
    80004614:	f2098993          	addi	s3,s3,-224 # 80028530 <log>
    80004618:	99a6                	add	s3,s3,s1
    8000461a:	854e                	mv	a0,s3
    8000461c:	ffffc097          	auipc	ra,0xffffc
    80004620:	62a080e7          	jalr	1578(ra) # 80000c46 <acquire>
  for (i = 0; i < log[dev].lh.n; i++) {
    80004624:	0349a603          	lw	a2,52(s3)
    80004628:	0cc05263          	blez	a2,800046ec <log_write+0x13e>
    if (log[dev].lh.block[i] == b->blockno)   // log absorbtion
    8000462c:	00ca2583          	lw	a1,12(s4)
    80004630:	0389a783          	lw	a5,56(s3)
    80004634:	0cb78a63          	beq	a5,a1,80004708 <log_write+0x15a>
    80004638:	00024797          	auipc	a5,0x24
    8000463c:	f3478793          	addi	a5,a5,-204 # 8002856c <log+0x3c>
    80004640:	97a6                	add	a5,a5,s1
  for (i = 0; i < log[dev].lh.n; i++) {
    80004642:	4701                	li	a4,0
    80004644:	2705                	addiw	a4,a4,1
    80004646:	06c70063          	beq	a4,a2,800046a6 <log_write+0xf8>
    if (log[dev].lh.block[i] == b->blockno)   // log absorbtion
    8000464a:	4394                	lw	a3,0(a5)
    8000464c:	0791                	addi	a5,a5,4
    8000464e:	feb69be3          	bne	a3,a1,80004644 <log_write+0x96>
      break;
  }
  log[dev].lh.block[i] = b->blockno;
    80004652:	02c00793          	li	a5,44
    80004656:	02f907b3          	mul	a5,s2,a5
    8000465a:	97ba                	add	a5,a5,a4
    8000465c:	07b1                	addi	a5,a5,12
    8000465e:	078a                	slli	a5,a5,0x2
    80004660:	00024717          	auipc	a4,0x24
    80004664:	ed070713          	addi	a4,a4,-304 # 80028530 <log>
    80004668:	97ba                	add	a5,a5,a4
    8000466a:	c78c                	sw	a1,8(a5)
  if (i == log[dev].lh.n) {  // Add new block to log?
    bpin(b);
    log[dev].lh.n++;
  }
  release(&log[dev].lock);
    8000466c:	854e                	mv	a0,s3
    8000466e:	ffffc097          	auipc	ra,0xffffc
    80004672:	648080e7          	jalr	1608(ra) # 80000cb6 <release>
}
    80004676:	70a2                	ld	ra,40(sp)
    80004678:	7402                	ld	s0,32(sp)
    8000467a:	64e2                	ld	s1,24(sp)
    8000467c:	6942                	ld	s2,16(sp)
    8000467e:	69a2                	ld	s3,8(sp)
    80004680:	6a02                	ld	s4,0(sp)
    80004682:	6145                	addi	sp,sp,48
    80004684:	8082                	ret
    panic("too big a transaction");
    80004686:	00004517          	auipc	a0,0x4
    8000468a:	0ea50513          	addi	a0,a0,234 # 80008770 <userret+0x6e0>
    8000468e:	ffffc097          	auipc	ra,0xffffc
    80004692:	ef0080e7          	jalr	-272(ra) # 8000057e <panic>
    panic("log_write outside of trans");
    80004696:	00004517          	auipc	a0,0x4
    8000469a:	0f250513          	addi	a0,a0,242 # 80008788 <userret+0x6f8>
    8000469e:	ffffc097          	auipc	ra,0xffffc
    800046a2:	ee0080e7          	jalr	-288(ra) # 8000057e <panic>
  log[dev].lh.block[i] = b->blockno;
    800046a6:	02c00793          	li	a5,44
    800046aa:	02f907b3          	mul	a5,s2,a5
    800046ae:	97b2                	add	a5,a5,a2
    800046b0:	07b1                	addi	a5,a5,12
    800046b2:	078a                	slli	a5,a5,0x2
    800046b4:	00024717          	auipc	a4,0x24
    800046b8:	e7c70713          	addi	a4,a4,-388 # 80028530 <log>
    800046bc:	97ba                	add	a5,a5,a4
    800046be:	00ca2703          	lw	a4,12(s4)
    800046c2:	c798                	sw	a4,8(a5)
    bpin(b);
    800046c4:	8552                	mv	a0,s4
    800046c6:	fffff097          	auipc	ra,0xfffff
    800046ca:	c46080e7          	jalr	-954(ra) # 8000330c <bpin>
    log[dev].lh.n++;
    800046ce:	0b000793          	li	a5,176
    800046d2:	02f907b3          	mul	a5,s2,a5
    800046d6:	00024917          	auipc	s2,0x24
    800046da:	e5a90913          	addi	s2,s2,-422 # 80028530 <log>
    800046de:	993e                	add	s2,s2,a5
    800046e0:	03492783          	lw	a5,52(s2)
    800046e4:	2785                	addiw	a5,a5,1
    800046e6:	02f92a23          	sw	a5,52(s2)
    800046ea:	b749                	j	8000466c <log_write+0xbe>
  log[dev].lh.block[i] = b->blockno;
    800046ec:	0b000793          	li	a5,176
    800046f0:	02f90733          	mul	a4,s2,a5
    800046f4:	00024797          	auipc	a5,0x24
    800046f8:	e3c78793          	addi	a5,a5,-452 # 80028530 <log>
    800046fc:	97ba                	add	a5,a5,a4
    800046fe:	00ca2703          	lw	a4,12(s4)
    80004702:	df98                	sw	a4,56(a5)
  if (i == log[dev].lh.n) {  // Add new block to log?
    80004704:	f625                	bnez	a2,8000466c <log_write+0xbe>
    80004706:	bf7d                	j	800046c4 <log_write+0x116>
  for (i = 0; i < log[dev].lh.n; i++) {
    80004708:	4701                	li	a4,0
    8000470a:	b7a1                	j	80004652 <log_write+0xa4>

000000008000470c <initsleeplock>:
#include "proc.h"
#include "sleeplock.h"

void
initsleeplock(struct sleeplock *lk, char *name)
{
    8000470c:	1101                	addi	sp,sp,-32
    8000470e:	ec06                	sd	ra,24(sp)
    80004710:	e822                	sd	s0,16(sp)
    80004712:	e426                	sd	s1,8(sp)
    80004714:	e04a                	sd	s2,0(sp)
    80004716:	1000                	addi	s0,sp,32
    80004718:	84aa                	mv	s1,a0
    8000471a:	892e                	mv	s2,a1
  initlock(&lk->lk, "sleep lock");
    8000471c:	00004597          	auipc	a1,0x4
    80004720:	08c58593          	addi	a1,a1,140 # 800087a8 <userret+0x718>
    80004724:	0521                	addi	a0,a0,8
    80004726:	ffffc097          	auipc	ra,0xffffc
    8000472a:	3d0080e7          	jalr	976(ra) # 80000af6 <initlock>
  lk->name = name;
    8000472e:	0324b423          	sd	s2,40(s1)
  lk->locked = 0;
    80004732:	0004a023          	sw	zero,0(s1)
  lk->pid = 0;
    80004736:	0204a823          	sw	zero,48(s1)
}
    8000473a:	60e2                	ld	ra,24(sp)
    8000473c:	6442                	ld	s0,16(sp)
    8000473e:	64a2                	ld	s1,8(sp)
    80004740:	6902                	ld	s2,0(sp)
    80004742:	6105                	addi	sp,sp,32
    80004744:	8082                	ret

0000000080004746 <acquiresleep>:

void
acquiresleep(struct sleeplock *lk)
{
    80004746:	1101                	addi	sp,sp,-32
    80004748:	ec06                	sd	ra,24(sp)
    8000474a:	e822                	sd	s0,16(sp)
    8000474c:	e426                	sd	s1,8(sp)
    8000474e:	e04a                	sd	s2,0(sp)
    80004750:	1000                	addi	s0,sp,32
    80004752:	84aa                	mv	s1,a0
  acquire(&lk->lk);
    80004754:	00850913          	addi	s2,a0,8
    80004758:	854a                	mv	a0,s2
    8000475a:	ffffc097          	auipc	ra,0xffffc
    8000475e:	4ec080e7          	jalr	1260(ra) # 80000c46 <acquire>
  while (lk->locked) {
    80004762:	409c                	lw	a5,0(s1)
    80004764:	cb89                	beqz	a5,80004776 <acquiresleep+0x30>
    sleep(lk, &lk->lk);
    80004766:	85ca                	mv	a1,s2
    80004768:	8526                	mv	a0,s1
    8000476a:	ffffe097          	auipc	ra,0xffffe
    8000476e:	c78080e7          	jalr	-904(ra) # 800023e2 <sleep>
  while (lk->locked) {
    80004772:	409c                	lw	a5,0(s1)
    80004774:	fbed                	bnez	a5,80004766 <acquiresleep+0x20>
  }
  lk->locked = 1;
    80004776:	4785                	li	a5,1
    80004778:	c09c                	sw	a5,0(s1)
  lk->pid = myproc()->pid;
    8000477a:	ffffd097          	auipc	ra,0xffffd
    8000477e:	48c080e7          	jalr	1164(ra) # 80001c06 <myproc>
    80004782:	413c                	lw	a5,64(a0)
    80004784:	d89c                	sw	a5,48(s1)
  release(&lk->lk);
    80004786:	854a                	mv	a0,s2
    80004788:	ffffc097          	auipc	ra,0xffffc
    8000478c:	52e080e7          	jalr	1326(ra) # 80000cb6 <release>
}
    80004790:	60e2                	ld	ra,24(sp)
    80004792:	6442                	ld	s0,16(sp)
    80004794:	64a2                	ld	s1,8(sp)
    80004796:	6902                	ld	s2,0(sp)
    80004798:	6105                	addi	sp,sp,32
    8000479a:	8082                	ret

000000008000479c <releasesleep>:

void
releasesleep(struct sleeplock *lk)
{
    8000479c:	1101                	addi	sp,sp,-32
    8000479e:	ec06                	sd	ra,24(sp)
    800047a0:	e822                	sd	s0,16(sp)
    800047a2:	e426                	sd	s1,8(sp)
    800047a4:	e04a                	sd	s2,0(sp)
    800047a6:	1000                	addi	s0,sp,32
    800047a8:	84aa                	mv	s1,a0
  acquire(&lk->lk);
    800047aa:	00850913          	addi	s2,a0,8
    800047ae:	854a                	mv	a0,s2
    800047b0:	ffffc097          	auipc	ra,0xffffc
    800047b4:	496080e7          	jalr	1174(ra) # 80000c46 <acquire>
  lk->locked = 0;
    800047b8:	0004a023          	sw	zero,0(s1)
  lk->pid = 0;
    800047bc:	0204a823          	sw	zero,48(s1)
  wakeup(lk);
    800047c0:	8526                	mv	a0,s1
    800047c2:	ffffe097          	auipc	ra,0xffffe
    800047c6:	da6080e7          	jalr	-602(ra) # 80002568 <wakeup>
  release(&lk->lk);
    800047ca:	854a                	mv	a0,s2
    800047cc:	ffffc097          	auipc	ra,0xffffc
    800047d0:	4ea080e7          	jalr	1258(ra) # 80000cb6 <release>
}
    800047d4:	60e2                	ld	ra,24(sp)
    800047d6:	6442                	ld	s0,16(sp)
    800047d8:	64a2                	ld	s1,8(sp)
    800047da:	6902                	ld	s2,0(sp)
    800047dc:	6105                	addi	sp,sp,32
    800047de:	8082                	ret

00000000800047e0 <holdingsleep>:

int
holdingsleep(struct sleeplock *lk)
{
    800047e0:	7179                	addi	sp,sp,-48
    800047e2:	f406                	sd	ra,40(sp)
    800047e4:	f022                	sd	s0,32(sp)
    800047e6:	ec26                	sd	s1,24(sp)
    800047e8:	e84a                	sd	s2,16(sp)
    800047ea:	e44e                	sd	s3,8(sp)
    800047ec:	1800                	addi	s0,sp,48
    800047ee:	84aa                	mv	s1,a0
  int r;
  
  acquire(&lk->lk);
    800047f0:	00850913          	addi	s2,a0,8
    800047f4:	854a                	mv	a0,s2
    800047f6:	ffffc097          	auipc	ra,0xffffc
    800047fa:	450080e7          	jalr	1104(ra) # 80000c46 <acquire>
  r = lk->locked && (lk->pid == myproc()->pid);
    800047fe:	409c                	lw	a5,0(s1)
    80004800:	ef99                	bnez	a5,8000481e <holdingsleep+0x3e>
    80004802:	4481                	li	s1,0
  release(&lk->lk);
    80004804:	854a                	mv	a0,s2
    80004806:	ffffc097          	auipc	ra,0xffffc
    8000480a:	4b0080e7          	jalr	1200(ra) # 80000cb6 <release>
  return r;
}
    8000480e:	8526                	mv	a0,s1
    80004810:	70a2                	ld	ra,40(sp)
    80004812:	7402                	ld	s0,32(sp)
    80004814:	64e2                	ld	s1,24(sp)
    80004816:	6942                	ld	s2,16(sp)
    80004818:	69a2                	ld	s3,8(sp)
    8000481a:	6145                	addi	sp,sp,48
    8000481c:	8082                	ret
  r = lk->locked && (lk->pid == myproc()->pid);
    8000481e:	0304a983          	lw	s3,48(s1)
    80004822:	ffffd097          	auipc	ra,0xffffd
    80004826:	3e4080e7          	jalr	996(ra) # 80001c06 <myproc>
    8000482a:	4124                	lw	s1,64(a0)
    8000482c:	413484b3          	sub	s1,s1,s3
    80004830:	0014b493          	seqz	s1,s1
    80004834:	bfc1                	j	80004804 <holdingsleep+0x24>

0000000080004836 <fileinit>:
  struct file file[NFILE];
} ftable;

void
fileinit(void)
{
    80004836:	1141                	addi	sp,sp,-16
    80004838:	e406                	sd	ra,8(sp)
    8000483a:	e022                	sd	s0,0(sp)
    8000483c:	0800                	addi	s0,sp,16
  initlock(&ftable.lock, "ftable");
    8000483e:	00004597          	auipc	a1,0x4
    80004842:	f7a58593          	addi	a1,a1,-134 # 800087b8 <userret+0x728>
    80004846:	00024517          	auipc	a0,0x24
    8000484a:	eea50513          	addi	a0,a0,-278 # 80028730 <ftable>
    8000484e:	ffffc097          	auipc	ra,0xffffc
    80004852:	2a8080e7          	jalr	680(ra) # 80000af6 <initlock>
}
    80004856:	60a2                	ld	ra,8(sp)
    80004858:	6402                	ld	s0,0(sp)
    8000485a:	0141                	addi	sp,sp,16
    8000485c:	8082                	ret

000000008000485e <filealloc>:

// Allocate a file structure.
struct file*
filealloc(void)
{
    8000485e:	1101                	addi	sp,sp,-32
    80004860:	ec06                	sd	ra,24(sp)
    80004862:	e822                	sd	s0,16(sp)
    80004864:	e426                	sd	s1,8(sp)
    80004866:	1000                	addi	s0,sp,32
  struct file *f;

  acquire(&ftable.lock);
    80004868:	00024517          	auipc	a0,0x24
    8000486c:	ec850513          	addi	a0,a0,-312 # 80028730 <ftable>
    80004870:	ffffc097          	auipc	ra,0xffffc
    80004874:	3d6080e7          	jalr	982(ra) # 80000c46 <acquire>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    if(f->ref == 0){
    80004878:	00024797          	auipc	a5,0x24
    8000487c:	eb878793          	addi	a5,a5,-328 # 80028730 <ftable>
    80004880:	53dc                	lw	a5,36(a5)
    80004882:	cb8d                	beqz	a5,800048b4 <filealloc+0x56>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    80004884:	00024497          	auipc	s1,0x24
    80004888:	ef448493          	addi	s1,s1,-268 # 80028778 <ftable+0x48>
    8000488c:	00025717          	auipc	a4,0x25
    80004890:	e6470713          	addi	a4,a4,-412 # 800296f0 <ftable+0xfc0>
    if(f->ref == 0){
    80004894:	40dc                	lw	a5,4(s1)
    80004896:	c39d                	beqz	a5,800048bc <filealloc+0x5e>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    80004898:	02848493          	addi	s1,s1,40
    8000489c:	fee49ce3          	bne	s1,a4,80004894 <filealloc+0x36>
      f->ref = 1;
      release(&ftable.lock);
      return f;
    }
  }
  release(&ftable.lock);
    800048a0:	00024517          	auipc	a0,0x24
    800048a4:	e9050513          	addi	a0,a0,-368 # 80028730 <ftable>
    800048a8:	ffffc097          	auipc	ra,0xffffc
    800048ac:	40e080e7          	jalr	1038(ra) # 80000cb6 <release>
  return 0;
    800048b0:	4481                	li	s1,0
    800048b2:	a839                	j	800048d0 <filealloc+0x72>
  for(f = ftable.file; f < ftable.file + NFILE; f++){
    800048b4:	00024497          	auipc	s1,0x24
    800048b8:	e9c48493          	addi	s1,s1,-356 # 80028750 <ftable+0x20>
      f->ref = 1;
    800048bc:	4785                	li	a5,1
    800048be:	c0dc                	sw	a5,4(s1)
      release(&ftable.lock);
    800048c0:	00024517          	auipc	a0,0x24
    800048c4:	e7050513          	addi	a0,a0,-400 # 80028730 <ftable>
    800048c8:	ffffc097          	auipc	ra,0xffffc
    800048cc:	3ee080e7          	jalr	1006(ra) # 80000cb6 <release>
}
    800048d0:	8526                	mv	a0,s1
    800048d2:	60e2                	ld	ra,24(sp)
    800048d4:	6442                	ld	s0,16(sp)
    800048d6:	64a2                	ld	s1,8(sp)
    800048d8:	6105                	addi	sp,sp,32
    800048da:	8082                	ret

00000000800048dc <filedup>:

// Increment ref count for file f.
struct file*
filedup(struct file *f)
{
    800048dc:	1101                	addi	sp,sp,-32
    800048de:	ec06                	sd	ra,24(sp)
    800048e0:	e822                	sd	s0,16(sp)
    800048e2:	e426                	sd	s1,8(sp)
    800048e4:	1000                	addi	s0,sp,32
    800048e6:	84aa                	mv	s1,a0
  acquire(&ftable.lock);
    800048e8:	00024517          	auipc	a0,0x24
    800048ec:	e4850513          	addi	a0,a0,-440 # 80028730 <ftable>
    800048f0:	ffffc097          	auipc	ra,0xffffc
    800048f4:	356080e7          	jalr	854(ra) # 80000c46 <acquire>
  if(f->ref < 1)
    800048f8:	40dc                	lw	a5,4(s1)
    800048fa:	02f05263          	blez	a5,8000491e <filedup+0x42>
    panic("filedup");
  f->ref++;
    800048fe:	2785                	addiw	a5,a5,1
    80004900:	c0dc                	sw	a5,4(s1)
  release(&ftable.lock);
    80004902:	00024517          	auipc	a0,0x24
    80004906:	e2e50513          	addi	a0,a0,-466 # 80028730 <ftable>
    8000490a:	ffffc097          	auipc	ra,0xffffc
    8000490e:	3ac080e7          	jalr	940(ra) # 80000cb6 <release>
  return f;
}
    80004912:	8526                	mv	a0,s1
    80004914:	60e2                	ld	ra,24(sp)
    80004916:	6442                	ld	s0,16(sp)
    80004918:	64a2                	ld	s1,8(sp)
    8000491a:	6105                	addi	sp,sp,32
    8000491c:	8082                	ret
    panic("filedup");
    8000491e:	00004517          	auipc	a0,0x4
    80004922:	ea250513          	addi	a0,a0,-350 # 800087c0 <userret+0x730>
    80004926:	ffffc097          	auipc	ra,0xffffc
    8000492a:	c58080e7          	jalr	-936(ra) # 8000057e <panic>

000000008000492e <fileclose>:

// Close file f.  (Decrement ref count, close when reaches 0.)
void
fileclose(struct file *f)
{
    8000492e:	7139                	addi	sp,sp,-64
    80004930:	fc06                	sd	ra,56(sp)
    80004932:	f822                	sd	s0,48(sp)
    80004934:	f426                	sd	s1,40(sp)
    80004936:	f04a                	sd	s2,32(sp)
    80004938:	ec4e                	sd	s3,24(sp)
    8000493a:	e852                	sd	s4,16(sp)
    8000493c:	e456                	sd	s5,8(sp)
    8000493e:	0080                	addi	s0,sp,64
    80004940:	84aa                	mv	s1,a0
  struct file ff;

  acquire(&ftable.lock);
    80004942:	00024517          	auipc	a0,0x24
    80004946:	dee50513          	addi	a0,a0,-530 # 80028730 <ftable>
    8000494a:	ffffc097          	auipc	ra,0xffffc
    8000494e:	2fc080e7          	jalr	764(ra) # 80000c46 <acquire>
  if(f->ref < 1)
    80004952:	40dc                	lw	a5,4(s1)
    80004954:	06f05563          	blez	a5,800049be <fileclose+0x90>
    panic("fileclose");
  if(--f->ref > 0){
    80004958:	37fd                	addiw	a5,a5,-1
    8000495a:	0007871b          	sext.w	a4,a5
    8000495e:	c0dc                	sw	a5,4(s1)
    80004960:	06e04763          	bgtz	a4,800049ce <fileclose+0xa0>
    release(&ftable.lock);
    return;
  }
  ff = *f;
    80004964:	0004a903          	lw	s2,0(s1)
    80004968:	0094ca83          	lbu	s5,9(s1)
    8000496c:	0104ba03          	ld	s4,16(s1)
    80004970:	0184b983          	ld	s3,24(s1)
  f->ref = 0;
    80004974:	0004a223          	sw	zero,4(s1)
  f->type = FD_NONE;
    80004978:	0004a023          	sw	zero,0(s1)
  release(&ftable.lock);
    8000497c:	00024517          	auipc	a0,0x24
    80004980:	db450513          	addi	a0,a0,-588 # 80028730 <ftable>
    80004984:	ffffc097          	auipc	ra,0xffffc
    80004988:	332080e7          	jalr	818(ra) # 80000cb6 <release>

  if(ff.type == FD_PIPE){
    8000498c:	4785                	li	a5,1
    8000498e:	06f90163          	beq	s2,a5,800049f0 <fileclose+0xc2>
    pipeclose(ff.pipe, ff.writable);
  } else if(ff.type == FD_INODE || ff.type == FD_DEVICE){
    80004992:	3979                	addiw	s2,s2,-2
    80004994:	4785                	li	a5,1
    80004996:	0527e463          	bltu	a5,s2,800049de <fileclose+0xb0>
    begin_op(ff.ip->dev);
    8000499a:	0009a503          	lw	a0,0(s3)
    8000499e:	00000097          	auipc	ra,0x0
    800049a2:	9c4080e7          	jalr	-1596(ra) # 80004362 <begin_op>
    iput(ff.ip);
    800049a6:	854e                	mv	a0,s3
    800049a8:	fffff097          	auipc	ra,0xfffff
    800049ac:	0dc080e7          	jalr	220(ra) # 80003a84 <iput>
    end_op(ff.ip->dev);
    800049b0:	0009a503          	lw	a0,0(s3)
    800049b4:	00000097          	auipc	ra,0x0
    800049b8:	a58080e7          	jalr	-1448(ra) # 8000440c <end_op>
    800049bc:	a00d                	j	800049de <fileclose+0xb0>
    panic("fileclose");
    800049be:	00004517          	auipc	a0,0x4
    800049c2:	e0a50513          	addi	a0,a0,-502 # 800087c8 <userret+0x738>
    800049c6:	ffffc097          	auipc	ra,0xffffc
    800049ca:	bb8080e7          	jalr	-1096(ra) # 8000057e <panic>
    release(&ftable.lock);
    800049ce:	00024517          	auipc	a0,0x24
    800049d2:	d6250513          	addi	a0,a0,-670 # 80028730 <ftable>
    800049d6:	ffffc097          	auipc	ra,0xffffc
    800049da:	2e0080e7          	jalr	736(ra) # 80000cb6 <release>
  }
}
    800049de:	70e2                	ld	ra,56(sp)
    800049e0:	7442                	ld	s0,48(sp)
    800049e2:	74a2                	ld	s1,40(sp)
    800049e4:	7902                	ld	s2,32(sp)
    800049e6:	69e2                	ld	s3,24(sp)
    800049e8:	6a42                	ld	s4,16(sp)
    800049ea:	6aa2                	ld	s5,8(sp)
    800049ec:	6121                	addi	sp,sp,64
    800049ee:	8082                	ret
    pipeclose(ff.pipe, ff.writable);
    800049f0:	85d6                	mv	a1,s5
    800049f2:	8552                	mv	a0,s4
    800049f4:	00000097          	auipc	ra,0x0
    800049f8:	376080e7          	jalr	886(ra) # 80004d6a <pipeclose>
    800049fc:	b7cd                	j	800049de <fileclose+0xb0>

00000000800049fe <filestat>:

// Get metadata about file f.
// addr is a user virtual address, pointing to a struct stat.
int
filestat(struct file *f, uint64 addr)
{
    800049fe:	715d                	addi	sp,sp,-80
    80004a00:	e486                	sd	ra,72(sp)
    80004a02:	e0a2                	sd	s0,64(sp)
    80004a04:	fc26                	sd	s1,56(sp)
    80004a06:	f84a                	sd	s2,48(sp)
    80004a08:	f44e                	sd	s3,40(sp)
    80004a0a:	0880                	addi	s0,sp,80
    80004a0c:	84aa                	mv	s1,a0
    80004a0e:	89ae                	mv	s3,a1
  struct proc *p = myproc();
    80004a10:	ffffd097          	auipc	ra,0xffffd
    80004a14:	1f6080e7          	jalr	502(ra) # 80001c06 <myproc>
  struct stat st;
  
  if(f->type == FD_INODE || f->type == FD_DEVICE){
    80004a18:	409c                	lw	a5,0(s1)
    80004a1a:	37f9                	addiw	a5,a5,-2
    80004a1c:	4705                	li	a4,1
    80004a1e:	04f76763          	bltu	a4,a5,80004a6c <filestat+0x6e>
    80004a22:	892a                	mv	s2,a0
    ilock(f->ip);
    80004a24:	6c88                	ld	a0,24(s1)
    80004a26:	fffff097          	auipc	ra,0xfffff
    80004a2a:	f4e080e7          	jalr	-178(ra) # 80003974 <ilock>
    stati(f->ip, &st);
    80004a2e:	fb840593          	addi	a1,s0,-72
    80004a32:	6c88                	ld	a0,24(s1)
    80004a34:	fffff097          	auipc	ra,0xfffff
    80004a38:	1a8080e7          	jalr	424(ra) # 80003bdc <stati>
    iunlock(f->ip);
    80004a3c:	6c88                	ld	a0,24(s1)
    80004a3e:	fffff097          	auipc	ra,0xfffff
    80004a42:	ffa080e7          	jalr	-6(ra) # 80003a38 <iunlock>
    if(copyout(p->pagetable, addr, (char *)&st, sizeof(st)) < 0)
    80004a46:	46e1                	li	a3,24
    80004a48:	fb840613          	addi	a2,s0,-72
    80004a4c:	85ce                	mv	a1,s3
    80004a4e:	05893503          	ld	a0,88(s2)
    80004a52:	ffffd097          	auipc	ra,0xffffd
    80004a56:	e90080e7          	jalr	-368(ra) # 800018e2 <copyout>
    80004a5a:	41f5551b          	sraiw	a0,a0,0x1f
      return -1;
    return 0;
  }
  return -1;
}
    80004a5e:	60a6                	ld	ra,72(sp)
    80004a60:	6406                	ld	s0,64(sp)
    80004a62:	74e2                	ld	s1,56(sp)
    80004a64:	7942                	ld	s2,48(sp)
    80004a66:	79a2                	ld	s3,40(sp)
    80004a68:	6161                	addi	sp,sp,80
    80004a6a:	8082                	ret
  return -1;
    80004a6c:	557d                	li	a0,-1
    80004a6e:	bfc5                	j	80004a5e <filestat+0x60>

0000000080004a70 <fileread>:

// Read from file f.
// addr is a user virtual address.
int
fileread(struct file *f, uint64 addr, int n)
{
    80004a70:	7179                	addi	sp,sp,-48
    80004a72:	f406                	sd	ra,40(sp)
    80004a74:	f022                	sd	s0,32(sp)
    80004a76:	ec26                	sd	s1,24(sp)
    80004a78:	e84a                	sd	s2,16(sp)
    80004a7a:	e44e                	sd	s3,8(sp)
    80004a7c:	1800                	addi	s0,sp,48
  int r = 0;

  if(f->readable == 0)
    80004a7e:	00854783          	lbu	a5,8(a0)
    80004a82:	c7c5                	beqz	a5,80004b2a <fileread+0xba>
    80004a84:	89b2                	mv	s3,a2
    80004a86:	892e                	mv	s2,a1
    80004a88:	84aa                	mv	s1,a0
    return -1;

  if(f->type == FD_PIPE){
    80004a8a:	411c                	lw	a5,0(a0)
    80004a8c:	4705                	li	a4,1
    80004a8e:	04e78963          	beq	a5,a4,80004ae0 <fileread+0x70>
    r = piperead(f->pipe, addr, n);
  } else if(f->type == FD_DEVICE){
    80004a92:	470d                	li	a4,3
    80004a94:	04e78d63          	beq	a5,a4,80004aee <fileread+0x7e>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].read)
      return -1;
    r = devsw[f->major].read(f, 1, addr, n);
  } else if(f->type == FD_INODE){
    80004a98:	4709                	li	a4,2
    80004a9a:	08e79063          	bne	a5,a4,80004b1a <fileread+0xaa>
    ilock(f->ip);
    80004a9e:	6d08                	ld	a0,24(a0)
    80004aa0:	fffff097          	auipc	ra,0xfffff
    80004aa4:	ed4080e7          	jalr	-300(ra) # 80003974 <ilock>
    if((r = readi(f->ip, 1, addr, f->off, n)) > 0)
    80004aa8:	874e                	mv	a4,s3
    80004aaa:	5094                	lw	a3,32(s1)
    80004aac:	864a                	mv	a2,s2
    80004aae:	4585                	li	a1,1
    80004ab0:	6c88                	ld	a0,24(s1)
    80004ab2:	fffff097          	auipc	ra,0xfffff
    80004ab6:	154080e7          	jalr	340(ra) # 80003c06 <readi>
    80004aba:	892a                	mv	s2,a0
    80004abc:	00a05563          	blez	a0,80004ac6 <fileread+0x56>
      f->off += r;
    80004ac0:	509c                	lw	a5,32(s1)
    80004ac2:	9fa9                	addw	a5,a5,a0
    80004ac4:	d09c                	sw	a5,32(s1)
    iunlock(f->ip);
    80004ac6:	6c88                	ld	a0,24(s1)
    80004ac8:	fffff097          	auipc	ra,0xfffff
    80004acc:	f70080e7          	jalr	-144(ra) # 80003a38 <iunlock>
  } else {
    panic("fileread");
  }

  return r;
}
    80004ad0:	854a                	mv	a0,s2
    80004ad2:	70a2                	ld	ra,40(sp)
    80004ad4:	7402                	ld	s0,32(sp)
    80004ad6:	64e2                	ld	s1,24(sp)
    80004ad8:	6942                	ld	s2,16(sp)
    80004ada:	69a2                	ld	s3,8(sp)
    80004adc:	6145                	addi	sp,sp,48
    80004ade:	8082                	ret
    r = piperead(f->pipe, addr, n);
    80004ae0:	6908                	ld	a0,16(a0)
    80004ae2:	00000097          	auipc	ra,0x0
    80004ae6:	412080e7          	jalr	1042(ra) # 80004ef4 <piperead>
    80004aea:	892a                	mv	s2,a0
    80004aec:	b7d5                	j	80004ad0 <fileread+0x60>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].read)
    80004aee:	02451783          	lh	a5,36(a0)
    80004af2:	03079693          	slli	a3,a5,0x30
    80004af6:	92c1                	srli	a3,a3,0x30
    80004af8:	4725                	li	a4,9
    80004afa:	02d76a63          	bltu	a4,a3,80004b2e <fileread+0xbe>
    80004afe:	0792                	slli	a5,a5,0x4
    80004b00:	00024717          	auipc	a4,0x24
    80004b04:	b9070713          	addi	a4,a4,-1136 # 80028690 <devsw>
    80004b08:	97ba                	add	a5,a5,a4
    80004b0a:	639c                	ld	a5,0(a5)
    80004b0c:	c39d                	beqz	a5,80004b32 <fileread+0xc2>
    r = devsw[f->major].read(f, 1, addr, n);
    80004b0e:	86b2                	mv	a3,a2
    80004b10:	862e                	mv	a2,a1
    80004b12:	4585                	li	a1,1
    80004b14:	9782                	jalr	a5
    80004b16:	892a                	mv	s2,a0
    80004b18:	bf65                	j	80004ad0 <fileread+0x60>
    panic("fileread");
    80004b1a:	00004517          	auipc	a0,0x4
    80004b1e:	cbe50513          	addi	a0,a0,-834 # 800087d8 <userret+0x748>
    80004b22:	ffffc097          	auipc	ra,0xffffc
    80004b26:	a5c080e7          	jalr	-1444(ra) # 8000057e <panic>
    return -1;
    80004b2a:	597d                	li	s2,-1
    80004b2c:	b755                	j	80004ad0 <fileread+0x60>
      return -1;
    80004b2e:	597d                	li	s2,-1
    80004b30:	b745                	j	80004ad0 <fileread+0x60>
    80004b32:	597d                	li	s2,-1
    80004b34:	bf71                	j	80004ad0 <fileread+0x60>

0000000080004b36 <filewrite>:
int
filewrite(struct file *f, uint64 addr, int n)
{
  int r, ret = 0;

  if(f->writable == 0)
    80004b36:	00954783          	lbu	a5,9(a0)
    80004b3a:	14078663          	beqz	a5,80004c86 <filewrite+0x150>
{
    80004b3e:	715d                	addi	sp,sp,-80
    80004b40:	e486                	sd	ra,72(sp)
    80004b42:	e0a2                	sd	s0,64(sp)
    80004b44:	fc26                	sd	s1,56(sp)
    80004b46:	f84a                	sd	s2,48(sp)
    80004b48:	f44e                	sd	s3,40(sp)
    80004b4a:	f052                	sd	s4,32(sp)
    80004b4c:	ec56                	sd	s5,24(sp)
    80004b4e:	e85a                	sd	s6,16(sp)
    80004b50:	e45e                	sd	s7,8(sp)
    80004b52:	e062                	sd	s8,0(sp)
    80004b54:	0880                	addi	s0,sp,80
    80004b56:	8ab2                	mv	s5,a2
    80004b58:	8b2e                	mv	s6,a1
    80004b5a:	84aa                	mv	s1,a0
    return -1;

  if(f->type == FD_PIPE){
    80004b5c:	411c                	lw	a5,0(a0)
    80004b5e:	4705                	li	a4,1
    80004b60:	02e78263          	beq	a5,a4,80004b84 <filewrite+0x4e>
    ret = pipewrite(f->pipe, addr, n);
  } else if(f->type == FD_DEVICE){
    80004b64:	470d                	li	a4,3
    80004b66:	02e78563          	beq	a5,a4,80004b90 <filewrite+0x5a>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].write)
      return -1;
    ret = devsw[f->major].write(f, 1, addr, n);
  } else if(f->type == FD_INODE){
    80004b6a:	4709                	li	a4,2
    80004b6c:	10e79563          	bne	a5,a4,80004c76 <filewrite+0x140>
    // and 2 blocks of slop for non-aligned writes.
    // this really belongs lower down, since writei()
    // might be writing a device like the console.
    int max = ((MAXOPBLOCKS-1-1-2) / 2) * BSIZE;
    int i = 0;
    while(i < n){
    80004b70:	0ec05f63          	blez	a2,80004c6e <filewrite+0x138>
    int i = 0;
    80004b74:	4901                	li	s2,0
    80004b76:	6b85                	lui	s7,0x1
    80004b78:	c00b8b93          	addi	s7,s7,-1024 # c00 <_entry-0x7ffff400>
    80004b7c:	6c05                	lui	s8,0x1
    80004b7e:	c00c0c1b          	addiw	s8,s8,-1024
    80004b82:	a851                	j	80004c16 <filewrite+0xe0>
    ret = pipewrite(f->pipe, addr, n);
    80004b84:	6908                	ld	a0,16(a0)
    80004b86:	00000097          	auipc	ra,0x0
    80004b8a:	254080e7          	jalr	596(ra) # 80004dda <pipewrite>
    80004b8e:	a865                	j	80004c46 <filewrite+0x110>
    if(f->major < 0 || f->major >= NDEV || !devsw[f->major].write)
    80004b90:	02451783          	lh	a5,36(a0)
    80004b94:	03079693          	slli	a3,a5,0x30
    80004b98:	92c1                	srli	a3,a3,0x30
    80004b9a:	4725                	li	a4,9
    80004b9c:	0ed76763          	bltu	a4,a3,80004c8a <filewrite+0x154>
    80004ba0:	0792                	slli	a5,a5,0x4
    80004ba2:	00024717          	auipc	a4,0x24
    80004ba6:	aee70713          	addi	a4,a4,-1298 # 80028690 <devsw>
    80004baa:	97ba                	add	a5,a5,a4
    80004bac:	679c                	ld	a5,8(a5)
    80004bae:	c3e5                	beqz	a5,80004c8e <filewrite+0x158>
    ret = devsw[f->major].write(f, 1, addr, n);
    80004bb0:	86b2                	mv	a3,a2
    80004bb2:	862e                	mv	a2,a1
    80004bb4:	4585                	li	a1,1
    80004bb6:	9782                	jalr	a5
    80004bb8:	a079                	j	80004c46 <filewrite+0x110>
    80004bba:	00098a1b          	sext.w	s4,s3
      int n1 = n - i;
      if(n1 > max)
        n1 = max;

      begin_op(f->ip->dev);
    80004bbe:	6c9c                	ld	a5,24(s1)
    80004bc0:	4388                	lw	a0,0(a5)
    80004bc2:	fffff097          	auipc	ra,0xfffff
    80004bc6:	7a0080e7          	jalr	1952(ra) # 80004362 <begin_op>
      ilock(f->ip);
    80004bca:	6c88                	ld	a0,24(s1)
    80004bcc:	fffff097          	auipc	ra,0xfffff
    80004bd0:	da8080e7          	jalr	-600(ra) # 80003974 <ilock>
      if ((r = writei(f->ip, 1, addr + i, f->off, n1)) > 0)
    80004bd4:	8752                	mv	a4,s4
    80004bd6:	5094                	lw	a3,32(s1)
    80004bd8:	01690633          	add	a2,s2,s6
    80004bdc:	4585                	li	a1,1
    80004bde:	6c88                	ld	a0,24(s1)
    80004be0:	fffff097          	auipc	ra,0xfffff
    80004be4:	11a080e7          	jalr	282(ra) # 80003cfa <writei>
    80004be8:	89aa                	mv	s3,a0
    80004bea:	02a05e63          	blez	a0,80004c26 <filewrite+0xf0>
        f->off += r;
    80004bee:	509c                	lw	a5,32(s1)
    80004bf0:	9fa9                	addw	a5,a5,a0
    80004bf2:	d09c                	sw	a5,32(s1)
      iunlock(f->ip);
    80004bf4:	6c88                	ld	a0,24(s1)
    80004bf6:	fffff097          	auipc	ra,0xfffff
    80004bfa:	e42080e7          	jalr	-446(ra) # 80003a38 <iunlock>
      end_op(f->ip->dev);
    80004bfe:	6c9c                	ld	a5,24(s1)
    80004c00:	4388                	lw	a0,0(a5)
    80004c02:	00000097          	auipc	ra,0x0
    80004c06:	80a080e7          	jalr	-2038(ra) # 8000440c <end_op>

      if(r < 0)
        break;
      if(r != n1)
    80004c0a:	05499a63          	bne	s3,s4,80004c5e <filewrite+0x128>
        panic("short filewrite");
      i += r;
    80004c0e:	012a093b          	addw	s2,s4,s2
    while(i < n){
    80004c12:	03595763          	ble	s5,s2,80004c40 <filewrite+0x10a>
      int n1 = n - i;
    80004c16:	412a87bb          	subw	a5,s5,s2
      if(n1 > max)
    80004c1a:	89be                	mv	s3,a5
    80004c1c:	2781                	sext.w	a5,a5
    80004c1e:	f8fbdee3          	ble	a5,s7,80004bba <filewrite+0x84>
    80004c22:	89e2                	mv	s3,s8
    80004c24:	bf59                	j	80004bba <filewrite+0x84>
      iunlock(f->ip);
    80004c26:	6c88                	ld	a0,24(s1)
    80004c28:	fffff097          	auipc	ra,0xfffff
    80004c2c:	e10080e7          	jalr	-496(ra) # 80003a38 <iunlock>
      end_op(f->ip->dev);
    80004c30:	6c9c                	ld	a5,24(s1)
    80004c32:	4388                	lw	a0,0(a5)
    80004c34:	fffff097          	auipc	ra,0xfffff
    80004c38:	7d8080e7          	jalr	2008(ra) # 8000440c <end_op>
      if(r < 0)
    80004c3c:	fc09d7e3          	bgez	s3,80004c0a <filewrite+0xd4>
    }
    ret = (i == n ? n : -1);
    80004c40:	8556                	mv	a0,s5
    80004c42:	032a9863          	bne	s5,s2,80004c72 <filewrite+0x13c>
  } else {
    panic("filewrite");
  }

  return ret;
}
    80004c46:	60a6                	ld	ra,72(sp)
    80004c48:	6406                	ld	s0,64(sp)
    80004c4a:	74e2                	ld	s1,56(sp)
    80004c4c:	7942                	ld	s2,48(sp)
    80004c4e:	79a2                	ld	s3,40(sp)
    80004c50:	7a02                	ld	s4,32(sp)
    80004c52:	6ae2                	ld	s5,24(sp)
    80004c54:	6b42                	ld	s6,16(sp)
    80004c56:	6ba2                	ld	s7,8(sp)
    80004c58:	6c02                	ld	s8,0(sp)
    80004c5a:	6161                	addi	sp,sp,80
    80004c5c:	8082                	ret
        panic("short filewrite");
    80004c5e:	00004517          	auipc	a0,0x4
    80004c62:	b8a50513          	addi	a0,a0,-1142 # 800087e8 <userret+0x758>
    80004c66:	ffffc097          	auipc	ra,0xffffc
    80004c6a:	918080e7          	jalr	-1768(ra) # 8000057e <panic>
    int i = 0;
    80004c6e:	4901                	li	s2,0
    80004c70:	bfc1                	j	80004c40 <filewrite+0x10a>
    ret = (i == n ? n : -1);
    80004c72:	557d                	li	a0,-1
    80004c74:	bfc9                	j	80004c46 <filewrite+0x110>
    panic("filewrite");
    80004c76:	00004517          	auipc	a0,0x4
    80004c7a:	b8250513          	addi	a0,a0,-1150 # 800087f8 <userret+0x768>
    80004c7e:	ffffc097          	auipc	ra,0xffffc
    80004c82:	900080e7          	jalr	-1792(ra) # 8000057e <panic>
    return -1;
    80004c86:	557d                	li	a0,-1
}
    80004c88:	8082                	ret
      return -1;
    80004c8a:	557d                	li	a0,-1
    80004c8c:	bf6d                	j	80004c46 <filewrite+0x110>
    80004c8e:	557d                	li	a0,-1
    80004c90:	bf5d                	j	80004c46 <filewrite+0x110>

0000000080004c92 <pipealloc>:
  int writeopen;  // write fd is still open
};

int
pipealloc(struct file **f0, struct file **f1)
{
    80004c92:	7179                	addi	sp,sp,-48
    80004c94:	f406                	sd	ra,40(sp)
    80004c96:	f022                	sd	s0,32(sp)
    80004c98:	ec26                	sd	s1,24(sp)
    80004c9a:	e84a                	sd	s2,16(sp)
    80004c9c:	e44e                	sd	s3,8(sp)
    80004c9e:	e052                	sd	s4,0(sp)
    80004ca0:	1800                	addi	s0,sp,48
    80004ca2:	84aa                	mv	s1,a0
    80004ca4:	892e                	mv	s2,a1
  struct pipe *pi;

  pi = 0;
  *f0 = *f1 = 0;
    80004ca6:	0005b023          	sd	zero,0(a1)
    80004caa:	00053023          	sd	zero,0(a0)
  if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0)
    80004cae:	00000097          	auipc	ra,0x0
    80004cb2:	bb0080e7          	jalr	-1104(ra) # 8000485e <filealloc>
    80004cb6:	e088                	sd	a0,0(s1)
    80004cb8:	c549                	beqz	a0,80004d42 <pipealloc+0xb0>
    80004cba:	00000097          	auipc	ra,0x0
    80004cbe:	ba4080e7          	jalr	-1116(ra) # 8000485e <filealloc>
    80004cc2:	00a93023          	sd	a0,0(s2)
    80004cc6:	c925                	beqz	a0,80004d36 <pipealloc+0xa4>
    goto bad;
  if((pi = (struct pipe*)kalloc()) == 0)
    80004cc8:	ffffc097          	auipc	ra,0xffffc
    80004ccc:	d2c080e7          	jalr	-724(ra) # 800009f4 <kalloc>
    80004cd0:	89aa                	mv	s3,a0
    80004cd2:	cd39                	beqz	a0,80004d30 <pipealloc+0x9e>
    goto bad;
  pi->readopen = 1;
    80004cd4:	4a05                	li	s4,1
    80004cd6:	23452423          	sw	s4,552(a0)
  pi->writeopen = 1;
    80004cda:	23452623          	sw	s4,556(a0)
  pi->nwrite = 0;
    80004cde:	22052223          	sw	zero,548(a0)
  pi->nread = 0;
    80004ce2:	22052023          	sw	zero,544(a0)
  memset(&pi->lock, 0, sizeof(pi->lock));
    80004ce6:	02000613          	li	a2,32
    80004cea:	4581                	li	a1,0
    80004cec:	ffffc097          	auipc	ra,0xffffc
    80004cf0:	1f0080e7          	jalr	496(ra) # 80000edc <memset>
  (*f0)->type = FD_PIPE;
    80004cf4:	609c                	ld	a5,0(s1)
    80004cf6:	0147a023          	sw	s4,0(a5)
  (*f0)->readable = 1;
    80004cfa:	609c                	ld	a5,0(s1)
    80004cfc:	01478423          	sb	s4,8(a5)
  (*f0)->writable = 0;
    80004d00:	609c                	ld	a5,0(s1)
    80004d02:	000784a3          	sb	zero,9(a5)
  (*f0)->pipe = pi;
    80004d06:	609c                	ld	a5,0(s1)
    80004d08:	0137b823          	sd	s3,16(a5)
  (*f1)->type = FD_PIPE;
    80004d0c:	00093783          	ld	a5,0(s2)
    80004d10:	0147a023          	sw	s4,0(a5)
  (*f1)->readable = 0;
    80004d14:	00093783          	ld	a5,0(s2)
    80004d18:	00078423          	sb	zero,8(a5)
  (*f1)->writable = 1;
    80004d1c:	00093783          	ld	a5,0(s2)
    80004d20:	014784a3          	sb	s4,9(a5)
  (*f1)->pipe = pi;
    80004d24:	00093783          	ld	a5,0(s2)
    80004d28:	0137b823          	sd	s3,16(a5)
  return 0;
    80004d2c:	4501                	li	a0,0
    80004d2e:	a025                	j	80004d56 <pipealloc+0xc4>

 bad:
  if(pi)
    kfree((char*)pi);
  if(*f0)
    80004d30:	6088                	ld	a0,0(s1)
    80004d32:	e501                	bnez	a0,80004d3a <pipealloc+0xa8>
    80004d34:	a039                	j	80004d42 <pipealloc+0xb0>
    80004d36:	6088                	ld	a0,0(s1)
    80004d38:	c51d                	beqz	a0,80004d66 <pipealloc+0xd4>
    fileclose(*f0);
    80004d3a:	00000097          	auipc	ra,0x0
    80004d3e:	bf4080e7          	jalr	-1036(ra) # 8000492e <fileclose>
  if(*f1)
    80004d42:	00093783          	ld	a5,0(s2)
    fileclose(*f1);
  return -1;
    80004d46:	557d                	li	a0,-1
  if(*f1)
    80004d48:	c799                	beqz	a5,80004d56 <pipealloc+0xc4>
    fileclose(*f1);
    80004d4a:	853e                	mv	a0,a5
    80004d4c:	00000097          	auipc	ra,0x0
    80004d50:	be2080e7          	jalr	-1054(ra) # 8000492e <fileclose>
  return -1;
    80004d54:	557d                	li	a0,-1
}
    80004d56:	70a2                	ld	ra,40(sp)
    80004d58:	7402                	ld	s0,32(sp)
    80004d5a:	64e2                	ld	s1,24(sp)
    80004d5c:	6942                	ld	s2,16(sp)
    80004d5e:	69a2                	ld	s3,8(sp)
    80004d60:	6a02                	ld	s4,0(sp)
    80004d62:	6145                	addi	sp,sp,48
    80004d64:	8082                	ret
  return -1;
    80004d66:	557d                	li	a0,-1
    80004d68:	b7fd                	j	80004d56 <pipealloc+0xc4>

0000000080004d6a <pipeclose>:

void
pipeclose(struct pipe *pi, int writable)
{
    80004d6a:	1101                	addi	sp,sp,-32
    80004d6c:	ec06                	sd	ra,24(sp)
    80004d6e:	e822                	sd	s0,16(sp)
    80004d70:	e426                	sd	s1,8(sp)
    80004d72:	e04a                	sd	s2,0(sp)
    80004d74:	1000                	addi	s0,sp,32
    80004d76:	84aa                	mv	s1,a0
    80004d78:	892e                	mv	s2,a1
  acquire(&pi->lock);
    80004d7a:	ffffc097          	auipc	ra,0xffffc
    80004d7e:	ecc080e7          	jalr	-308(ra) # 80000c46 <acquire>
  if(writable){
    80004d82:	02090d63          	beqz	s2,80004dbc <pipeclose+0x52>
    pi->writeopen = 0;
    80004d86:	2204a623          	sw	zero,556(s1)
    wakeup(&pi->nread);
    80004d8a:	22048513          	addi	a0,s1,544
    80004d8e:	ffffd097          	auipc	ra,0xffffd
    80004d92:	7da080e7          	jalr	2010(ra) # 80002568 <wakeup>
  } else {
    pi->readopen = 0;
    wakeup(&pi->nwrite);
  }
  if(pi->readopen == 0 && pi->writeopen == 0){
    80004d96:	2284b783          	ld	a5,552(s1)
    80004d9a:	eb95                	bnez	a5,80004dce <pipeclose+0x64>
    release(&pi->lock);
    80004d9c:	8526                	mv	a0,s1
    80004d9e:	ffffc097          	auipc	ra,0xffffc
    80004da2:	f18080e7          	jalr	-232(ra) # 80000cb6 <release>
    kfree((char*)pi);
    80004da6:	8526                	mv	a0,s1
    80004da8:	ffffc097          	auipc	ra,0xffffc
    80004dac:	afc080e7          	jalr	-1284(ra) # 800008a4 <kfree>
  } else
    release(&pi->lock);
}
    80004db0:	60e2                	ld	ra,24(sp)
    80004db2:	6442                	ld	s0,16(sp)
    80004db4:	64a2                	ld	s1,8(sp)
    80004db6:	6902                	ld	s2,0(sp)
    80004db8:	6105                	addi	sp,sp,32
    80004dba:	8082                	ret
    pi->readopen = 0;
    80004dbc:	2204a423          	sw	zero,552(s1)
    wakeup(&pi->nwrite);
    80004dc0:	22448513          	addi	a0,s1,548
    80004dc4:	ffffd097          	auipc	ra,0xffffd
    80004dc8:	7a4080e7          	jalr	1956(ra) # 80002568 <wakeup>
    80004dcc:	b7e9                	j	80004d96 <pipeclose+0x2c>
    release(&pi->lock);
    80004dce:	8526                	mv	a0,s1
    80004dd0:	ffffc097          	auipc	ra,0xffffc
    80004dd4:	ee6080e7          	jalr	-282(ra) # 80000cb6 <release>
}
    80004dd8:	bfe1                	j	80004db0 <pipeclose+0x46>

0000000080004dda <pipewrite>:

int
pipewrite(struct pipe *pi, uint64 addr, int n)
{
    80004dda:	7159                	addi	sp,sp,-112
    80004ddc:	f486                	sd	ra,104(sp)
    80004dde:	f0a2                	sd	s0,96(sp)
    80004de0:	eca6                	sd	s1,88(sp)
    80004de2:	e8ca                	sd	s2,80(sp)
    80004de4:	e4ce                	sd	s3,72(sp)
    80004de6:	e0d2                	sd	s4,64(sp)
    80004de8:	fc56                	sd	s5,56(sp)
    80004dea:	f85a                	sd	s6,48(sp)
    80004dec:	f45e                	sd	s7,40(sp)
    80004dee:	f062                	sd	s8,32(sp)
    80004df0:	ec66                	sd	s9,24(sp)
    80004df2:	1880                	addi	s0,sp,112
    80004df4:	84aa                	mv	s1,a0
    80004df6:	8bae                	mv	s7,a1
    80004df8:	8b32                	mv	s6,a2
  int i;
  char ch;
  struct proc *pr = myproc();
    80004dfa:	ffffd097          	auipc	ra,0xffffd
    80004dfe:	e0c080e7          	jalr	-500(ra) # 80001c06 <myproc>
    80004e02:	8c2a                	mv	s8,a0

  acquire(&pi->lock);
    80004e04:	8526                	mv	a0,s1
    80004e06:	ffffc097          	auipc	ra,0xffffc
    80004e0a:	e40080e7          	jalr	-448(ra) # 80000c46 <acquire>
  for(i = 0; i < n; i++){
    80004e0e:	0d605663          	blez	s6,80004eda <pipewrite+0x100>
    80004e12:	8926                	mv	s2,s1
    80004e14:	fffb0a9b          	addiw	s5,s6,-1
    80004e18:	1a82                	slli	s5,s5,0x20
    80004e1a:	020ada93          	srli	s5,s5,0x20
    80004e1e:	001b8793          	addi	a5,s7,1
    80004e22:	9abe                	add	s5,s5,a5
    while(pi->nwrite == pi->nread + PIPESIZE){  //DOC: pipewrite-full
      if(pi->readopen == 0 || myproc()->killed){
        release(&pi->lock);
        return -1;
      }
      wakeup(&pi->nread);
    80004e24:	22048a13          	addi	s4,s1,544
      sleep(&pi->nwrite, &pi->lock);
    80004e28:	22448993          	addi	s3,s1,548
    }
    if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
    80004e2c:	5cfd                	li	s9,-1
    while(pi->nwrite == pi->nread + PIPESIZE){  //DOC: pipewrite-full
    80004e2e:	2204a783          	lw	a5,544(s1)
    80004e32:	2244a703          	lw	a4,548(s1)
    80004e36:	2007879b          	addiw	a5,a5,512
    80004e3a:	06f71463          	bne	a4,a5,80004ea2 <pipewrite+0xc8>
      if(pi->readopen == 0 || myproc()->killed){
    80004e3e:	2284a783          	lw	a5,552(s1)
    80004e42:	cf8d                	beqz	a5,80004e7c <pipewrite+0xa2>
    80004e44:	ffffd097          	auipc	ra,0xffffd
    80004e48:	dc2080e7          	jalr	-574(ra) # 80001c06 <myproc>
    80004e4c:	5d1c                	lw	a5,56(a0)
    80004e4e:	e79d                	bnez	a5,80004e7c <pipewrite+0xa2>
      wakeup(&pi->nread);
    80004e50:	8552                	mv	a0,s4
    80004e52:	ffffd097          	auipc	ra,0xffffd
    80004e56:	716080e7          	jalr	1814(ra) # 80002568 <wakeup>
      sleep(&pi->nwrite, &pi->lock);
    80004e5a:	85ca                	mv	a1,s2
    80004e5c:	854e                	mv	a0,s3
    80004e5e:	ffffd097          	auipc	ra,0xffffd
    80004e62:	584080e7          	jalr	1412(ra) # 800023e2 <sleep>
    while(pi->nwrite == pi->nread + PIPESIZE){  //DOC: pipewrite-full
    80004e66:	2204a783          	lw	a5,544(s1)
    80004e6a:	2244a703          	lw	a4,548(s1)
    80004e6e:	2007879b          	addiw	a5,a5,512
    80004e72:	02f71863          	bne	a4,a5,80004ea2 <pipewrite+0xc8>
      if(pi->readopen == 0 || myproc()->killed){
    80004e76:	2284a783          	lw	a5,552(s1)
    80004e7a:	f7e9                	bnez	a5,80004e44 <pipewrite+0x6a>
        release(&pi->lock);
    80004e7c:	8526                	mv	a0,s1
    80004e7e:	ffffc097          	auipc	ra,0xffffc
    80004e82:	e38080e7          	jalr	-456(ra) # 80000cb6 <release>
        return -1;
    80004e86:	557d                	li	a0,-1
    pi->data[pi->nwrite++ % PIPESIZE] = ch;
  }
  wakeup(&pi->nread);
  release(&pi->lock);
  return n;
}
    80004e88:	70a6                	ld	ra,104(sp)
    80004e8a:	7406                	ld	s0,96(sp)
    80004e8c:	64e6                	ld	s1,88(sp)
    80004e8e:	6946                	ld	s2,80(sp)
    80004e90:	69a6                	ld	s3,72(sp)
    80004e92:	6a06                	ld	s4,64(sp)
    80004e94:	7ae2                	ld	s5,56(sp)
    80004e96:	7b42                	ld	s6,48(sp)
    80004e98:	7ba2                	ld	s7,40(sp)
    80004e9a:	7c02                	ld	s8,32(sp)
    80004e9c:	6ce2                	ld	s9,24(sp)
    80004e9e:	6165                	addi	sp,sp,112
    80004ea0:	8082                	ret
    if(copyin(pr->pagetable, &ch, addr + i, 1) == -1)
    80004ea2:	4685                	li	a3,1
    80004ea4:	865e                	mv	a2,s7
    80004ea6:	f9f40593          	addi	a1,s0,-97
    80004eaa:	058c3503          	ld	a0,88(s8) # 1058 <_entry-0x7fffefa8>
    80004eae:	ffffd097          	auipc	ra,0xffffd
    80004eb2:	ac0080e7          	jalr	-1344(ra) # 8000196e <copyin>
    80004eb6:	03950263          	beq	a0,s9,80004eda <pipewrite+0x100>
    pi->data[pi->nwrite++ % PIPESIZE] = ch;
    80004eba:	2244a783          	lw	a5,548(s1)
    80004ebe:	0017871b          	addiw	a4,a5,1
    80004ec2:	22e4a223          	sw	a4,548(s1)
    80004ec6:	1ff7f793          	andi	a5,a5,511
    80004eca:	97a6                	add	a5,a5,s1
    80004ecc:	f9f44703          	lbu	a4,-97(s0)
    80004ed0:	02e78023          	sb	a4,32(a5)
  for(i = 0; i < n; i++){
    80004ed4:	0b85                	addi	s7,s7,1
    80004ed6:	f55b9ce3          	bne	s7,s5,80004e2e <pipewrite+0x54>
  wakeup(&pi->nread);
    80004eda:	22048513          	addi	a0,s1,544
    80004ede:	ffffd097          	auipc	ra,0xffffd
    80004ee2:	68a080e7          	jalr	1674(ra) # 80002568 <wakeup>
  release(&pi->lock);
    80004ee6:	8526                	mv	a0,s1
    80004ee8:	ffffc097          	auipc	ra,0xffffc
    80004eec:	dce080e7          	jalr	-562(ra) # 80000cb6 <release>
  return n;
    80004ef0:	855a                	mv	a0,s6
    80004ef2:	bf59                	j	80004e88 <pipewrite+0xae>

0000000080004ef4 <piperead>:

int
piperead(struct pipe *pi, uint64 addr, int n)
{
    80004ef4:	715d                	addi	sp,sp,-80
    80004ef6:	e486                	sd	ra,72(sp)
    80004ef8:	e0a2                	sd	s0,64(sp)
    80004efa:	fc26                	sd	s1,56(sp)
    80004efc:	f84a                	sd	s2,48(sp)
    80004efe:	f44e                	sd	s3,40(sp)
    80004f00:	f052                	sd	s4,32(sp)
    80004f02:	ec56                	sd	s5,24(sp)
    80004f04:	e85a                	sd	s6,16(sp)
    80004f06:	0880                	addi	s0,sp,80
    80004f08:	84aa                	mv	s1,a0
    80004f0a:	89ae                	mv	s3,a1
    80004f0c:	8a32                	mv	s4,a2
  int i;
  struct proc *pr = myproc();
    80004f0e:	ffffd097          	auipc	ra,0xffffd
    80004f12:	cf8080e7          	jalr	-776(ra) # 80001c06 <myproc>
    80004f16:	8aaa                	mv	s5,a0
  char ch;

  acquire(&pi->lock);
    80004f18:	8526                	mv	a0,s1
    80004f1a:	ffffc097          	auipc	ra,0xffffc
    80004f1e:	d2c080e7          	jalr	-724(ra) # 80000c46 <acquire>
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    80004f22:	2204a703          	lw	a4,544(s1)
    80004f26:	2244a783          	lw	a5,548(s1)
    80004f2a:	06f71b63          	bne	a4,a5,80004fa0 <piperead+0xac>
    80004f2e:	8926                	mv	s2,s1
    80004f30:	22c4a783          	lw	a5,556(s1)
    80004f34:	cb85                	beqz	a5,80004f64 <piperead+0x70>
    if(myproc()->killed){
      release(&pi->lock);
      return -1;
    }
    sleep(&pi->nread, &pi->lock); //DOC: piperead-sleep
    80004f36:	22048b13          	addi	s6,s1,544
    if(myproc()->killed){
    80004f3a:	ffffd097          	auipc	ra,0xffffd
    80004f3e:	ccc080e7          	jalr	-820(ra) # 80001c06 <myproc>
    80004f42:	5d1c                	lw	a5,56(a0)
    80004f44:	e7b9                	bnez	a5,80004f92 <piperead+0x9e>
    sleep(&pi->nread, &pi->lock); //DOC: piperead-sleep
    80004f46:	85ca                	mv	a1,s2
    80004f48:	855a                	mv	a0,s6
    80004f4a:	ffffd097          	auipc	ra,0xffffd
    80004f4e:	498080e7          	jalr	1176(ra) # 800023e2 <sleep>
  while(pi->nread == pi->nwrite && pi->writeopen){  //DOC: pipe-empty
    80004f52:	2204a703          	lw	a4,544(s1)
    80004f56:	2244a783          	lw	a5,548(s1)
    80004f5a:	04f71363          	bne	a4,a5,80004fa0 <piperead+0xac>
    80004f5e:	22c4a783          	lw	a5,556(s1)
    80004f62:	ffe1                	bnez	a5,80004f3a <piperead+0x46>
  }
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    if(pi->nread == pi->nwrite)
    80004f64:	4901                	li	s2,0
      break;
    ch = pi->data[pi->nread++ % PIPESIZE];
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
      break;
  }
  wakeup(&pi->nwrite);  //DOC: piperead-wakeup
    80004f66:	22448513          	addi	a0,s1,548
    80004f6a:	ffffd097          	auipc	ra,0xffffd
    80004f6e:	5fe080e7          	jalr	1534(ra) # 80002568 <wakeup>
  release(&pi->lock);
    80004f72:	8526                	mv	a0,s1
    80004f74:	ffffc097          	auipc	ra,0xffffc
    80004f78:	d42080e7          	jalr	-702(ra) # 80000cb6 <release>
  return i;
}
    80004f7c:	854a                	mv	a0,s2
    80004f7e:	60a6                	ld	ra,72(sp)
    80004f80:	6406                	ld	s0,64(sp)
    80004f82:	74e2                	ld	s1,56(sp)
    80004f84:	7942                	ld	s2,48(sp)
    80004f86:	79a2                	ld	s3,40(sp)
    80004f88:	7a02                	ld	s4,32(sp)
    80004f8a:	6ae2                	ld	s5,24(sp)
    80004f8c:	6b42                	ld	s6,16(sp)
    80004f8e:	6161                	addi	sp,sp,80
    80004f90:	8082                	ret
      release(&pi->lock);
    80004f92:	8526                	mv	a0,s1
    80004f94:	ffffc097          	auipc	ra,0xffffc
    80004f98:	d22080e7          	jalr	-734(ra) # 80000cb6 <release>
      return -1;
    80004f9c:	597d                	li	s2,-1
    80004f9e:	bff9                	j	80004f7c <piperead+0x88>
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    80004fa0:	4901                	li	s2,0
    80004fa2:	fd4052e3          	blez	s4,80004f66 <piperead+0x72>
    if(pi->nread == pi->nwrite)
    80004fa6:	2204a783          	lw	a5,544(s1)
    80004faa:	4901                	li	s2,0
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
    80004fac:	5b7d                	li	s6,-1
    ch = pi->data[pi->nread++ % PIPESIZE];
    80004fae:	0017871b          	addiw	a4,a5,1
    80004fb2:	22e4a023          	sw	a4,544(s1)
    80004fb6:	1ff7f793          	andi	a5,a5,511
    80004fba:	97a6                	add	a5,a5,s1
    80004fbc:	0207c783          	lbu	a5,32(a5)
    80004fc0:	faf40fa3          	sb	a5,-65(s0)
    if(copyout(pr->pagetable, addr + i, &ch, 1) == -1)
    80004fc4:	4685                	li	a3,1
    80004fc6:	fbf40613          	addi	a2,s0,-65
    80004fca:	85ce                	mv	a1,s3
    80004fcc:	058ab503          	ld	a0,88(s5)
    80004fd0:	ffffd097          	auipc	ra,0xffffd
    80004fd4:	912080e7          	jalr	-1774(ra) # 800018e2 <copyout>
    80004fd8:	f96507e3          	beq	a0,s6,80004f66 <piperead+0x72>
  for(i = 0; i < n; i++){  //DOC: piperead-copy
    80004fdc:	2905                	addiw	s2,s2,1
    80004fde:	f92a04e3          	beq	s4,s2,80004f66 <piperead+0x72>
    if(pi->nread == pi->nwrite)
    80004fe2:	2204a783          	lw	a5,544(s1)
    80004fe6:	0985                	addi	s3,s3,1
    80004fe8:	2244a703          	lw	a4,548(s1)
    80004fec:	fcf711e3          	bne	a4,a5,80004fae <piperead+0xba>
    80004ff0:	bf9d                	j	80004f66 <piperead+0x72>

0000000080004ff2 <exec>:

static int loadseg(pde_t *pgdir, uint64 addr, struct inode *ip, uint offset, uint sz);

int
exec(char *path, char **argv)
{
    80004ff2:	de010113          	addi	sp,sp,-544
    80004ff6:	20113c23          	sd	ra,536(sp)
    80004ffa:	20813823          	sd	s0,528(sp)
    80004ffe:	20913423          	sd	s1,520(sp)
    80005002:	21213023          	sd	s2,512(sp)
    80005006:	ffce                	sd	s3,504(sp)
    80005008:	fbd2                	sd	s4,496(sp)
    8000500a:	f7d6                	sd	s5,488(sp)
    8000500c:	f3da                	sd	s6,480(sp)
    8000500e:	efde                	sd	s7,472(sp)
    80005010:	ebe2                	sd	s8,464(sp)
    80005012:	e7e6                	sd	s9,456(sp)
    80005014:	e3ea                	sd	s10,448(sp)
    80005016:	ff6e                	sd	s11,440(sp)
    80005018:	1400                	addi	s0,sp,544
    8000501a:	892a                	mv	s2,a0
    8000501c:	dea43823          	sd	a0,-528(s0)
    80005020:	deb43c23          	sd	a1,-520(s0)
  uint64 argc, sz, sp, ustack[MAXARG+1], stackbase;
  struct elfhdr elf;
  struct inode *ip;
  struct proghdr ph;
  pagetable_t pagetable = 0, oldpagetable;
  struct proc *p = myproc();
    80005024:	ffffd097          	auipc	ra,0xffffd
    80005028:	be2080e7          	jalr	-1054(ra) # 80001c06 <myproc>
    8000502c:	84aa                	mv	s1,a0

  begin_op(ROOTDEV);
    8000502e:	4501                	li	a0,0
    80005030:	fffff097          	auipc	ra,0xfffff
    80005034:	332080e7          	jalr	818(ra) # 80004362 <begin_op>

  if((ip = namei(path)) == 0){
    80005038:	854a                	mv	a0,s2
    8000503a:	fffff097          	auipc	ra,0xfffff
    8000503e:	0ce080e7          	jalr	206(ra) # 80004108 <namei>
    80005042:	cd25                	beqz	a0,800050ba <exec+0xc8>
    80005044:	892a                	mv	s2,a0
    end_op(ROOTDEV);
    return -1;
  }
  ilock(ip);
    80005046:	fffff097          	auipc	ra,0xfffff
    8000504a:	92e080e7          	jalr	-1746(ra) # 80003974 <ilock>

  // Check ELF header
  if(readi(ip, 0, (uint64)&elf, 0, sizeof(elf)) != sizeof(elf))
    8000504e:	04000713          	li	a4,64
    80005052:	4681                	li	a3,0
    80005054:	e4840613          	addi	a2,s0,-440
    80005058:	4581                	li	a1,0
    8000505a:	854a                	mv	a0,s2
    8000505c:	fffff097          	auipc	ra,0xfffff
    80005060:	baa080e7          	jalr	-1110(ra) # 80003c06 <readi>
    80005064:	04000793          	li	a5,64
    80005068:	00f51a63          	bne	a0,a5,8000507c <exec+0x8a>
    goto bad;
  if(elf.magic != ELF_MAGIC)
    8000506c:	e4842703          	lw	a4,-440(s0)
    80005070:	464c47b7          	lui	a5,0x464c4
    80005074:	57f78793          	addi	a5,a5,1407 # 464c457f <_entry-0x39b3ba81>
    80005078:	04f70863          	beq	a4,a5,800050c8 <exec+0xd6>

 bad:
  if(pagetable)
    proc_freepagetable(pagetable, sz);
  if(ip){
    iunlockput(ip);
    8000507c:	854a                	mv	a0,s2
    8000507e:	fffff097          	auipc	ra,0xfffff
    80005082:	b36080e7          	jalr	-1226(ra) # 80003bb4 <iunlockput>
    end_op(ROOTDEV);
    80005086:	4501                	li	a0,0
    80005088:	fffff097          	auipc	ra,0xfffff
    8000508c:	384080e7          	jalr	900(ra) # 8000440c <end_op>
  }
  return -1;
    80005090:	557d                	li	a0,-1
}
    80005092:	21813083          	ld	ra,536(sp)
    80005096:	21013403          	ld	s0,528(sp)
    8000509a:	20813483          	ld	s1,520(sp)
    8000509e:	20013903          	ld	s2,512(sp)
    800050a2:	79fe                	ld	s3,504(sp)
    800050a4:	7a5e                	ld	s4,496(sp)
    800050a6:	7abe                	ld	s5,488(sp)
    800050a8:	7b1e                	ld	s6,480(sp)
    800050aa:	6bfe                	ld	s7,472(sp)
    800050ac:	6c5e                	ld	s8,464(sp)
    800050ae:	6cbe                	ld	s9,456(sp)
    800050b0:	6d1e                	ld	s10,448(sp)
    800050b2:	7dfa                	ld	s11,440(sp)
    800050b4:	22010113          	addi	sp,sp,544
    800050b8:	8082                	ret
    end_op(ROOTDEV);
    800050ba:	4501                	li	a0,0
    800050bc:	fffff097          	auipc	ra,0xfffff
    800050c0:	350080e7          	jalr	848(ra) # 8000440c <end_op>
    return -1;
    800050c4:	557d                	li	a0,-1
    800050c6:	b7f1                	j	80005092 <exec+0xa0>
  if((pagetable = proc_pagetable(p)) == 0)
    800050c8:	8526                	mv	a0,s1
    800050ca:	ffffd097          	auipc	ra,0xffffd
    800050ce:	c02080e7          	jalr	-1022(ra) # 80001ccc <proc_pagetable>
    800050d2:	e0a43423          	sd	a0,-504(s0)
    800050d6:	d15d                	beqz	a0,8000507c <exec+0x8a>
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    800050d8:	e6842983          	lw	s3,-408(s0)
    800050dc:	e8045783          	lhu	a5,-384(s0)
    800050e0:	cbed                	beqz	a5,800051d2 <exec+0x1e0>
  sz = 0;
    800050e2:	e0043023          	sd	zero,-512(s0)
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    800050e6:	4b01                	li	s6,0
    if(ph.vaddr % PGSIZE != 0)
    800050e8:	6c05                	lui	s8,0x1
    800050ea:	fffc0793          	addi	a5,s8,-1 # fff <_entry-0x7ffff001>
    800050ee:	def43423          	sd	a5,-536(s0)
  uint64 pa;

  if((va % PGSIZE) != 0)
    panic("loadseg: va must be page aligned");

  for(i = 0; i < sz; i += PGSIZE){
    800050f2:	6d05                	lui	s10,0x1
    800050f4:	a0a5                	j	8000515c <exec+0x16a>
    pa = walkaddr(pagetable, va + i);
    if(pa == 0)
      panic("loadseg: address should exist");
    800050f6:	00003517          	auipc	a0,0x3
    800050fa:	71250513          	addi	a0,a0,1810 # 80008808 <userret+0x778>
    800050fe:	ffffb097          	auipc	ra,0xffffb
    80005102:	480080e7          	jalr	1152(ra) # 8000057e <panic>
    if(sz - i < PGSIZE)
      n = sz - i;
    else
      n = PGSIZE;
    if(readi(ip, 0, (uint64)pa, offset+i, n) != n)
    80005106:	8756                	mv	a4,s5
    80005108:	009d86bb          	addw	a3,s11,s1
    8000510c:	4581                	li	a1,0
    8000510e:	854a                	mv	a0,s2
    80005110:	fffff097          	auipc	ra,0xfffff
    80005114:	af6080e7          	jalr	-1290(ra) # 80003c06 <readi>
    80005118:	2501                	sext.w	a0,a0
    8000511a:	10aa9563          	bne	s5,a0,80005224 <exec+0x232>
  for(i = 0; i < sz; i += PGSIZE){
    8000511e:	009d04bb          	addw	s1,s10,s1
    80005122:	77fd                	lui	a5,0xfffff
    80005124:	01478a3b          	addw	s4,a5,s4
    80005128:	0374f363          	bleu	s7,s1,8000514e <exec+0x15c>
    pa = walkaddr(pagetable, va + i);
    8000512c:	02049593          	slli	a1,s1,0x20
    80005130:	9181                	srli	a1,a1,0x20
    80005132:	95e6                	add	a1,a1,s9
    80005134:	e0843503          	ld	a0,-504(s0)
    80005138:	ffffc097          	auipc	ra,0xffffc
    8000513c:	1c6080e7          	jalr	454(ra) # 800012fe <walkaddr>
    80005140:	862a                	mv	a2,a0
    if(pa == 0)
    80005142:	d955                	beqz	a0,800050f6 <exec+0x104>
      n = PGSIZE;
    80005144:	8ae2                	mv	s5,s8
    if(sz - i < PGSIZE)
    80005146:	fd8a70e3          	bleu	s8,s4,80005106 <exec+0x114>
      n = sz - i;
    8000514a:	8ad2                	mv	s5,s4
    8000514c:	bf6d                	j	80005106 <exec+0x114>
  for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){
    8000514e:	2b05                	addiw	s6,s6,1
    80005150:	0389899b          	addiw	s3,s3,56
    80005154:	e8045783          	lhu	a5,-384(s0)
    80005158:	06fb5f63          	ble	a5,s6,800051d6 <exec+0x1e4>
    if(readi(ip, 0, (uint64)&ph, off, sizeof(ph)) != sizeof(ph))
    8000515c:	2981                	sext.w	s3,s3
    8000515e:	03800713          	li	a4,56
    80005162:	86ce                	mv	a3,s3
    80005164:	e1040613          	addi	a2,s0,-496
    80005168:	4581                	li	a1,0
    8000516a:	854a                	mv	a0,s2
    8000516c:	fffff097          	auipc	ra,0xfffff
    80005170:	a9a080e7          	jalr	-1382(ra) # 80003c06 <readi>
    80005174:	03800793          	li	a5,56
    80005178:	0af51663          	bne	a0,a5,80005224 <exec+0x232>
    if(ph.type != ELF_PROG_LOAD)
    8000517c:	e1042783          	lw	a5,-496(s0)
    80005180:	4705                	li	a4,1
    80005182:	fce796e3          	bne	a5,a4,8000514e <exec+0x15c>
    if(ph.memsz < ph.filesz)
    80005186:	e3843603          	ld	a2,-456(s0)
    8000518a:	e3043783          	ld	a5,-464(s0)
    8000518e:	08f66b63          	bltu	a2,a5,80005224 <exec+0x232>
    if(ph.vaddr + ph.memsz < ph.vaddr)
    80005192:	e2043783          	ld	a5,-480(s0)
    80005196:	963e                	add	a2,a2,a5
    80005198:	08f66663          	bltu	a2,a5,80005224 <exec+0x232>
    if((sz = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
    8000519c:	e0043583          	ld	a1,-512(s0)
    800051a0:	e0843503          	ld	a0,-504(s0)
    800051a4:	ffffc097          	auipc	ra,0xffffc
    800051a8:	564080e7          	jalr	1380(ra) # 80001708 <uvmalloc>
    800051ac:	e0a43023          	sd	a0,-512(s0)
    800051b0:	c935                	beqz	a0,80005224 <exec+0x232>
    if(ph.vaddr % PGSIZE != 0)
    800051b2:	e2043c83          	ld	s9,-480(s0)
    800051b6:	de843783          	ld	a5,-536(s0)
    800051ba:	00fcf7b3          	and	a5,s9,a5
    800051be:	e3bd                	bnez	a5,80005224 <exec+0x232>
    if(loadseg(pagetable, ph.vaddr, ip, ph.off, ph.filesz) < 0)
    800051c0:	e1842d83          	lw	s11,-488(s0)
    800051c4:	e3042b83          	lw	s7,-464(s0)
  for(i = 0; i < sz; i += PGSIZE){
    800051c8:	f80b83e3          	beqz	s7,8000514e <exec+0x15c>
    800051cc:	8a5e                	mv	s4,s7
    800051ce:	4481                	li	s1,0
    800051d0:	bfb1                	j	8000512c <exec+0x13a>
  sz = 0;
    800051d2:	e0043023          	sd	zero,-512(s0)
  iunlockput(ip);
    800051d6:	854a                	mv	a0,s2
    800051d8:	fffff097          	auipc	ra,0xfffff
    800051dc:	9dc080e7          	jalr	-1572(ra) # 80003bb4 <iunlockput>
  end_op(ROOTDEV);
    800051e0:	4501                	li	a0,0
    800051e2:	fffff097          	auipc	ra,0xfffff
    800051e6:	22a080e7          	jalr	554(ra) # 8000440c <end_op>
  p = myproc();
    800051ea:	ffffd097          	auipc	ra,0xffffd
    800051ee:	a1c080e7          	jalr	-1508(ra) # 80001c06 <myproc>
    800051f2:	8b2a                	mv	s6,a0
  uint64 oldsz = p->sz;
    800051f4:	05053c83          	ld	s9,80(a0)
  sz = PGROUNDUP(sz);
    800051f8:	6585                	lui	a1,0x1
    800051fa:	15fd                	addi	a1,a1,-1
    800051fc:	e0043783          	ld	a5,-512(s0)
    80005200:	00b78d33          	add	s10,a5,a1
    80005204:	75fd                	lui	a1,0xfffff
    80005206:	00bd75b3          	and	a1,s10,a1
  if((sz = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
    8000520a:	6609                	lui	a2,0x2
    8000520c:	962e                	add	a2,a2,a1
    8000520e:	e0843483          	ld	s1,-504(s0)
    80005212:	8526                	mv	a0,s1
    80005214:	ffffc097          	auipc	ra,0xffffc
    80005218:	4f4080e7          	jalr	1268(ra) # 80001708 <uvmalloc>
    8000521c:	e0a43023          	sd	a0,-512(s0)
  ip = 0;
    80005220:	4901                	li	s2,0
  if((sz = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
    80005222:	ed09                	bnez	a0,8000523c <exec+0x24a>
    proc_freepagetable(pagetable, sz);
    80005224:	e0043583          	ld	a1,-512(s0)
    80005228:	e0843503          	ld	a0,-504(s0)
    8000522c:	ffffd097          	auipc	ra,0xffffd
    80005230:	ba0080e7          	jalr	-1120(ra) # 80001dcc <proc_freepagetable>
  if(ip){
    80005234:	e40914e3          	bnez	s2,8000507c <exec+0x8a>
  return -1;
    80005238:	557d                	li	a0,-1
    8000523a:	bda1                	j	80005092 <exec+0xa0>
  uvmclear(pagetable, sz-2*PGSIZE);
    8000523c:	75f9                	lui	a1,0xffffe
    8000523e:	892a                	mv	s2,a0
    80005240:	95aa                	add	a1,a1,a0
    80005242:	8526                	mv	a0,s1
    80005244:	ffffc097          	auipc	ra,0xffffc
    80005248:	66c080e7          	jalr	1644(ra) # 800018b0 <uvmclear>
  stackbase = sp - PGSIZE;
    8000524c:	7afd                	lui	s5,0xfffff
    8000524e:	9aca                	add	s5,s5,s2
  for(argc = 0; argv[argc]; argc++) {
    80005250:	df843783          	ld	a5,-520(s0)
    80005254:	6388                	ld	a0,0(a5)
    80005256:	c52d                	beqz	a0,800052c0 <exec+0x2ce>
    80005258:	e8840993          	addi	s3,s0,-376
    8000525c:	f8840b93          	addi	s7,s0,-120
    80005260:	4481                	li	s1,0
    sp -= strlen(argv[argc]) + 1;
    80005262:	ffffc097          	auipc	ra,0xffffc
    80005266:	e24080e7          	jalr	-476(ra) # 80001086 <strlen>
    8000526a:	2505                	addiw	a0,a0,1
    8000526c:	40a90933          	sub	s2,s2,a0
    sp -= sp % 16; // riscv sp must be 16-byte aligned
    80005270:	ff097913          	andi	s2,s2,-16
    if(sp < stackbase)
    80005274:	0f596f63          	bltu	s2,s5,80005372 <exec+0x380>
    if(copyout(pagetable, sp, argv[argc], strlen(argv[argc]) + 1) < 0)
    80005278:	df843c03          	ld	s8,-520(s0)
    8000527c:	000c3a03          	ld	s4,0(s8)
    80005280:	8552                	mv	a0,s4
    80005282:	ffffc097          	auipc	ra,0xffffc
    80005286:	e04080e7          	jalr	-508(ra) # 80001086 <strlen>
    8000528a:	0015069b          	addiw	a3,a0,1
    8000528e:	8652                	mv	a2,s4
    80005290:	85ca                	mv	a1,s2
    80005292:	e0843503          	ld	a0,-504(s0)
    80005296:	ffffc097          	auipc	ra,0xffffc
    8000529a:	64c080e7          	jalr	1612(ra) # 800018e2 <copyout>
    8000529e:	0c054c63          	bltz	a0,80005376 <exec+0x384>
    ustack[argc] = sp;
    800052a2:	0129b023          	sd	s2,0(s3)
  for(argc = 0; argv[argc]; argc++) {
    800052a6:	0485                	addi	s1,s1,1
    800052a8:	008c0793          	addi	a5,s8,8
    800052ac:	def43c23          	sd	a5,-520(s0)
    800052b0:	008c3503          	ld	a0,8(s8)
    800052b4:	c909                	beqz	a0,800052c6 <exec+0x2d4>
    if(argc >= MAXARG)
    800052b6:	09a1                	addi	s3,s3,8
    800052b8:	fb7995e3          	bne	s3,s7,80005262 <exec+0x270>
  ip = 0;
    800052bc:	4901                	li	s2,0
    800052be:	b79d                	j	80005224 <exec+0x232>
  sp = sz;
    800052c0:	e0043903          	ld	s2,-512(s0)
  for(argc = 0; argv[argc]; argc++) {
    800052c4:	4481                	li	s1,0
  ustack[argc] = 0;
    800052c6:	00349793          	slli	a5,s1,0x3
    800052ca:	f9040713          	addi	a4,s0,-112
    800052ce:	97ba                	add	a5,a5,a4
    800052d0:	ee07bc23          	sd	zero,-264(a5) # ffffffffffffeef8 <end+0xffffffff7ffcee9c>
  sp -= (argc+1) * sizeof(uint64);
    800052d4:	00148693          	addi	a3,s1,1
    800052d8:	068e                	slli	a3,a3,0x3
    800052da:	40d90933          	sub	s2,s2,a3
  sp -= sp % 16;
    800052de:	ff097993          	andi	s3,s2,-16
  ip = 0;
    800052e2:	4901                	li	s2,0
  if(sp < stackbase)
    800052e4:	f559e0e3          	bltu	s3,s5,80005224 <exec+0x232>
  if(copyout(pagetable, sp, (char *)ustack, (argc+1)*sizeof(uint64)) < 0)
    800052e8:	e8840613          	addi	a2,s0,-376
    800052ec:	85ce                	mv	a1,s3
    800052ee:	e0843503          	ld	a0,-504(s0)
    800052f2:	ffffc097          	auipc	ra,0xffffc
    800052f6:	5f0080e7          	jalr	1520(ra) # 800018e2 <copyout>
    800052fa:	08054063          	bltz	a0,8000537a <exec+0x388>
  p->tf->a1 = sp;
    800052fe:	060b3783          	ld	a5,96(s6)
    80005302:	0737bc23          	sd	s3,120(a5)
  for(last=s=path; *s; s++)
    80005306:	df043783          	ld	a5,-528(s0)
    8000530a:	0007c703          	lbu	a4,0(a5)
    8000530e:	cf11                	beqz	a4,8000532a <exec+0x338>
    80005310:	0785                	addi	a5,a5,1
    if(*s == '/')
    80005312:	02f00693          	li	a3,47
    80005316:	a029                	j	80005320 <exec+0x32e>
  for(last=s=path; *s; s++)
    80005318:	0785                	addi	a5,a5,1
    8000531a:	fff7c703          	lbu	a4,-1(a5)
    8000531e:	c711                	beqz	a4,8000532a <exec+0x338>
    if(*s == '/')
    80005320:	fed71ce3          	bne	a4,a3,80005318 <exec+0x326>
      last = s+1;
    80005324:	def43823          	sd	a5,-528(s0)
    80005328:	bfc5                	j	80005318 <exec+0x326>
  safestrcpy(p->name, last, sizeof(p->name));
    8000532a:	4641                	li	a2,16
    8000532c:	df043583          	ld	a1,-528(s0)
    80005330:	160b0513          	addi	a0,s6,352
    80005334:	ffffc097          	auipc	ra,0xffffc
    80005338:	d20080e7          	jalr	-736(ra) # 80001054 <safestrcpy>
  oldpagetable = p->pagetable;
    8000533c:	058b3503          	ld	a0,88(s6)
  p->pagetable = pagetable;
    80005340:	e0843783          	ld	a5,-504(s0)
    80005344:	04fb3c23          	sd	a5,88(s6)
  p->sz = sz;
    80005348:	e0043783          	ld	a5,-512(s0)
    8000534c:	04fb3823          	sd	a5,80(s6)
  p->tf->epc = elf.entry;  // initial program counter = main
    80005350:	060b3783          	ld	a5,96(s6)
    80005354:	e6043703          	ld	a4,-416(s0)
    80005358:	ef98                	sd	a4,24(a5)
  p->tf->sp = sp; // initial stack pointer
    8000535a:	060b3783          	ld	a5,96(s6)
    8000535e:	0337b823          	sd	s3,48(a5)
  proc_freepagetable(oldpagetable, oldsz);
    80005362:	85e6                	mv	a1,s9
    80005364:	ffffd097          	auipc	ra,0xffffd
    80005368:	a68080e7          	jalr	-1432(ra) # 80001dcc <proc_freepagetable>
  return argc; // this ends up in a0, the first argument to main(argc, argv)
    8000536c:	0004851b          	sext.w	a0,s1
    80005370:	b30d                	j	80005092 <exec+0xa0>
  ip = 0;
    80005372:	4901                	li	s2,0
    80005374:	bd45                	j	80005224 <exec+0x232>
    80005376:	4901                	li	s2,0
    80005378:	b575                	j	80005224 <exec+0x232>
    8000537a:	4901                	li	s2,0
    8000537c:	b565                	j	80005224 <exec+0x232>

000000008000537e <argfd>:

// Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file.
static int
argfd(int n, int *pfd, struct file **pf)
{
    8000537e:	7179                	addi	sp,sp,-48
    80005380:	f406                	sd	ra,40(sp)
    80005382:	f022                	sd	s0,32(sp)
    80005384:	ec26                	sd	s1,24(sp)
    80005386:	e84a                	sd	s2,16(sp)
    80005388:	1800                	addi	s0,sp,48
    8000538a:	892e                	mv	s2,a1
    8000538c:	84b2                	mv	s1,a2
  int fd;
  struct file *f;

  if(argint(n, &fd) < 0)
    8000538e:	fdc40593          	addi	a1,s0,-36
    80005392:	ffffe097          	auipc	ra,0xffffe
    80005396:	902080e7          	jalr	-1790(ra) # 80002c94 <argint>
    8000539a:	04054063          	bltz	a0,800053da <argfd+0x5c>
    return -1;
  if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
    8000539e:	fdc42703          	lw	a4,-36(s0)
    800053a2:	47bd                	li	a5,15
    800053a4:	02e7ed63          	bltu	a5,a4,800053de <argfd+0x60>
    800053a8:	ffffd097          	auipc	ra,0xffffd
    800053ac:	85e080e7          	jalr	-1954(ra) # 80001c06 <myproc>
    800053b0:	fdc42703          	lw	a4,-36(s0)
    800053b4:	01a70793          	addi	a5,a4,26
    800053b8:	078e                	slli	a5,a5,0x3
    800053ba:	953e                	add	a0,a0,a5
    800053bc:	651c                	ld	a5,8(a0)
    800053be:	c395                	beqz	a5,800053e2 <argfd+0x64>
    return -1;
  if(pfd)
    800053c0:	00090463          	beqz	s2,800053c8 <argfd+0x4a>
    *pfd = fd;
    800053c4:	00e92023          	sw	a4,0(s2)
  if(pf)
    *pf = f;
  return 0;
    800053c8:	4501                	li	a0,0
  if(pf)
    800053ca:	c091                	beqz	s1,800053ce <argfd+0x50>
    *pf = f;
    800053cc:	e09c                	sd	a5,0(s1)
}
    800053ce:	70a2                	ld	ra,40(sp)
    800053d0:	7402                	ld	s0,32(sp)
    800053d2:	64e2                	ld	s1,24(sp)
    800053d4:	6942                	ld	s2,16(sp)
    800053d6:	6145                	addi	sp,sp,48
    800053d8:	8082                	ret
    return -1;
    800053da:	557d                	li	a0,-1
    800053dc:	bfcd                	j	800053ce <argfd+0x50>
    return -1;
    800053de:	557d                	li	a0,-1
    800053e0:	b7fd                	j	800053ce <argfd+0x50>
    800053e2:	557d                	li	a0,-1
    800053e4:	b7ed                	j	800053ce <argfd+0x50>

00000000800053e6 <fdalloc>:

// Allocate a file descriptor for the given file.
// Takes over file reference from caller on success.
static int
fdalloc(struct file *f)
{
    800053e6:	1101                	addi	sp,sp,-32
    800053e8:	ec06                	sd	ra,24(sp)
    800053ea:	e822                	sd	s0,16(sp)
    800053ec:	e426                	sd	s1,8(sp)
    800053ee:	1000                	addi	s0,sp,32
    800053f0:	84aa                	mv	s1,a0
  int fd;
  struct proc *p = myproc();
    800053f2:	ffffd097          	auipc	ra,0xffffd
    800053f6:	814080e7          	jalr	-2028(ra) # 80001c06 <myproc>

  for(fd = 0; fd < NOFILE; fd++){
    if(p->ofile[fd] == 0){
    800053fa:	6d7c                	ld	a5,216(a0)
    800053fc:	c395                	beqz	a5,80005420 <fdalloc+0x3a>
    800053fe:	0e050713          	addi	a4,a0,224
  for(fd = 0; fd < NOFILE; fd++){
    80005402:	4785                	li	a5,1
    80005404:	4641                	li	a2,16
    if(p->ofile[fd] == 0){
    80005406:	6314                	ld	a3,0(a4)
    80005408:	ce89                	beqz	a3,80005422 <fdalloc+0x3c>
  for(fd = 0; fd < NOFILE; fd++){
    8000540a:	2785                	addiw	a5,a5,1
    8000540c:	0721                	addi	a4,a4,8
    8000540e:	fec79ce3          	bne	a5,a2,80005406 <fdalloc+0x20>
      p->ofile[fd] = f;
      return fd;
    }
  }
  return -1;
    80005412:	57fd                	li	a5,-1
}
    80005414:	853e                	mv	a0,a5
    80005416:	60e2                	ld	ra,24(sp)
    80005418:	6442                	ld	s0,16(sp)
    8000541a:	64a2                	ld	s1,8(sp)
    8000541c:	6105                	addi	sp,sp,32
    8000541e:	8082                	ret
  for(fd = 0; fd < NOFILE; fd++){
    80005420:	4781                	li	a5,0
      p->ofile[fd] = f;
    80005422:	01a78713          	addi	a4,a5,26
    80005426:	070e                	slli	a4,a4,0x3
    80005428:	953a                	add	a0,a0,a4
    8000542a:	e504                	sd	s1,8(a0)
      return fd;
    8000542c:	b7e5                	j	80005414 <fdalloc+0x2e>

000000008000542e <create>:
  return -1;
}

static struct inode*
create(char *path, short type, short major, short minor)
{
    8000542e:	715d                	addi	sp,sp,-80
    80005430:	e486                	sd	ra,72(sp)
    80005432:	e0a2                	sd	s0,64(sp)
    80005434:	fc26                	sd	s1,56(sp)
    80005436:	f84a                	sd	s2,48(sp)
    80005438:	f44e                	sd	s3,40(sp)
    8000543a:	f052                	sd	s4,32(sp)
    8000543c:	ec56                	sd	s5,24(sp)
    8000543e:	0880                	addi	s0,sp,80
    80005440:	89ae                	mv	s3,a1
    80005442:	8ab2                	mv	s5,a2
    80005444:	8a36                	mv	s4,a3
  struct inode *ip, *dp;
  char name[DIRSIZ];

  if((dp = nameiparent(path, name)) == 0)
    80005446:	fb040593          	addi	a1,s0,-80
    8000544a:	fffff097          	auipc	ra,0xfffff
    8000544e:	cdc080e7          	jalr	-804(ra) # 80004126 <nameiparent>
    80005452:	892a                	mv	s2,a0
    80005454:	12050f63          	beqz	a0,80005592 <create+0x164>
    return 0;

  ilock(dp);
    80005458:	ffffe097          	auipc	ra,0xffffe
    8000545c:	51c080e7          	jalr	1308(ra) # 80003974 <ilock>

  if((ip = dirlookup(dp, name, 0)) != 0){
    80005460:	4601                	li	a2,0
    80005462:	fb040593          	addi	a1,s0,-80
    80005466:	854a                	mv	a0,s2
    80005468:	fffff097          	auipc	ra,0xfffff
    8000546c:	9c6080e7          	jalr	-1594(ra) # 80003e2e <dirlookup>
    80005470:	84aa                	mv	s1,a0
    80005472:	c921                	beqz	a0,800054c2 <create+0x94>
    iunlockput(dp);
    80005474:	854a                	mv	a0,s2
    80005476:	ffffe097          	auipc	ra,0xffffe
    8000547a:	73e080e7          	jalr	1854(ra) # 80003bb4 <iunlockput>
    ilock(ip);
    8000547e:	8526                	mv	a0,s1
    80005480:	ffffe097          	auipc	ra,0xffffe
    80005484:	4f4080e7          	jalr	1268(ra) # 80003974 <ilock>
    if(type == T_FILE && (ip->type == T_FILE || ip->type == T_DEVICE))
    80005488:	2981                	sext.w	s3,s3
    8000548a:	4789                	li	a5,2
    8000548c:	02f99463          	bne	s3,a5,800054b4 <create+0x86>
    80005490:	04c4d783          	lhu	a5,76(s1)
    80005494:	37f9                	addiw	a5,a5,-2
    80005496:	17c2                	slli	a5,a5,0x30
    80005498:	93c1                	srli	a5,a5,0x30
    8000549a:	4705                	li	a4,1
    8000549c:	00f76c63          	bltu	a4,a5,800054b4 <create+0x86>
    panic("create: dirlink");

  iunlockput(dp);

  return ip;
}
    800054a0:	8526                	mv	a0,s1
    800054a2:	60a6                	ld	ra,72(sp)
    800054a4:	6406                	ld	s0,64(sp)
    800054a6:	74e2                	ld	s1,56(sp)
    800054a8:	7942                	ld	s2,48(sp)
    800054aa:	79a2                	ld	s3,40(sp)
    800054ac:	7a02                	ld	s4,32(sp)
    800054ae:	6ae2                	ld	s5,24(sp)
    800054b0:	6161                	addi	sp,sp,80
    800054b2:	8082                	ret
    iunlockput(ip);
    800054b4:	8526                	mv	a0,s1
    800054b6:	ffffe097          	auipc	ra,0xffffe
    800054ba:	6fe080e7          	jalr	1790(ra) # 80003bb4 <iunlockput>
    return 0;
    800054be:	4481                	li	s1,0
    800054c0:	b7c5                	j	800054a0 <create+0x72>
  if((ip = ialloc(dp->dev, type)) == 0)
    800054c2:	85ce                	mv	a1,s3
    800054c4:	00092503          	lw	a0,0(s2)
    800054c8:	ffffe097          	auipc	ra,0xffffe
    800054cc:	310080e7          	jalr	784(ra) # 800037d8 <ialloc>
    800054d0:	84aa                	mv	s1,a0
    800054d2:	c529                	beqz	a0,8000551c <create+0xee>
  ilock(ip);
    800054d4:	ffffe097          	auipc	ra,0xffffe
    800054d8:	4a0080e7          	jalr	1184(ra) # 80003974 <ilock>
  ip->major = major;
    800054dc:	05549723          	sh	s5,78(s1)
  ip->minor = minor;
    800054e0:	05449823          	sh	s4,80(s1)
  ip->nlink = 1;
    800054e4:	4785                	li	a5,1
    800054e6:	04f49923          	sh	a5,82(s1)
  iupdate(ip);
    800054ea:	8526                	mv	a0,s1
    800054ec:	ffffe097          	auipc	ra,0xffffe
    800054f0:	3bc080e7          	jalr	956(ra) # 800038a8 <iupdate>
  if(type == T_DIR){  // Create . and .. entries.
    800054f4:	2981                	sext.w	s3,s3
    800054f6:	4785                	li	a5,1
    800054f8:	02f98a63          	beq	s3,a5,8000552c <create+0xfe>
  if(dirlink(dp, name, ip->inum) < 0)
    800054fc:	40d0                	lw	a2,4(s1)
    800054fe:	fb040593          	addi	a1,s0,-80
    80005502:	854a                	mv	a0,s2
    80005504:	fffff097          	auipc	ra,0xfffff
    80005508:	b42080e7          	jalr	-1214(ra) # 80004046 <dirlink>
    8000550c:	06054b63          	bltz	a0,80005582 <create+0x154>
  iunlockput(dp);
    80005510:	854a                	mv	a0,s2
    80005512:	ffffe097          	auipc	ra,0xffffe
    80005516:	6a2080e7          	jalr	1698(ra) # 80003bb4 <iunlockput>
  return ip;
    8000551a:	b759                	j	800054a0 <create+0x72>
    panic("create: ialloc");
    8000551c:	00003517          	auipc	a0,0x3
    80005520:	30c50513          	addi	a0,a0,780 # 80008828 <userret+0x798>
    80005524:	ffffb097          	auipc	ra,0xffffb
    80005528:	05a080e7          	jalr	90(ra) # 8000057e <panic>
    dp->nlink++;  // for ".."
    8000552c:	05295783          	lhu	a5,82(s2)
    80005530:	2785                	addiw	a5,a5,1
    80005532:	04f91923          	sh	a5,82(s2)
    iupdate(dp);
    80005536:	854a                	mv	a0,s2
    80005538:	ffffe097          	auipc	ra,0xffffe
    8000553c:	370080e7          	jalr	880(ra) # 800038a8 <iupdate>
    if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0)
    80005540:	40d0                	lw	a2,4(s1)
    80005542:	00003597          	auipc	a1,0x3
    80005546:	2f658593          	addi	a1,a1,758 # 80008838 <userret+0x7a8>
    8000554a:	8526                	mv	a0,s1
    8000554c:	fffff097          	auipc	ra,0xfffff
    80005550:	afa080e7          	jalr	-1286(ra) # 80004046 <dirlink>
    80005554:	00054f63          	bltz	a0,80005572 <create+0x144>
    80005558:	00492603          	lw	a2,4(s2)
    8000555c:	00003597          	auipc	a1,0x3
    80005560:	2e458593          	addi	a1,a1,740 # 80008840 <userret+0x7b0>
    80005564:	8526                	mv	a0,s1
    80005566:	fffff097          	auipc	ra,0xfffff
    8000556a:	ae0080e7          	jalr	-1312(ra) # 80004046 <dirlink>
    8000556e:	f80557e3          	bgez	a0,800054fc <create+0xce>
      panic("create dots");
    80005572:	00003517          	auipc	a0,0x3
    80005576:	2d650513          	addi	a0,a0,726 # 80008848 <userret+0x7b8>
    8000557a:	ffffb097          	auipc	ra,0xffffb
    8000557e:	004080e7          	jalr	4(ra) # 8000057e <panic>
    panic("create: dirlink");
    80005582:	00003517          	auipc	a0,0x3
    80005586:	2d650513          	addi	a0,a0,726 # 80008858 <userret+0x7c8>
    8000558a:	ffffb097          	auipc	ra,0xffffb
    8000558e:	ff4080e7          	jalr	-12(ra) # 8000057e <panic>
    return 0;
    80005592:	84aa                	mv	s1,a0
    80005594:	b731                	j	800054a0 <create+0x72>

0000000080005596 <sys_dup>:
{
    80005596:	7179                	addi	sp,sp,-48
    80005598:	f406                	sd	ra,40(sp)
    8000559a:	f022                	sd	s0,32(sp)
    8000559c:	ec26                	sd	s1,24(sp)
    8000559e:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0)
    800055a0:	fd840613          	addi	a2,s0,-40
    800055a4:	4581                	li	a1,0
    800055a6:	4501                	li	a0,0
    800055a8:	00000097          	auipc	ra,0x0
    800055ac:	dd6080e7          	jalr	-554(ra) # 8000537e <argfd>
    return -1;
    800055b0:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0)
    800055b2:	02054363          	bltz	a0,800055d8 <sys_dup+0x42>
  if((fd=fdalloc(f)) < 0)
    800055b6:	fd843503          	ld	a0,-40(s0)
    800055ba:	00000097          	auipc	ra,0x0
    800055be:	e2c080e7          	jalr	-468(ra) # 800053e6 <fdalloc>
    800055c2:	84aa                	mv	s1,a0
    return -1;
    800055c4:	57fd                	li	a5,-1
  if((fd=fdalloc(f)) < 0)
    800055c6:	00054963          	bltz	a0,800055d8 <sys_dup+0x42>
  filedup(f);
    800055ca:	fd843503          	ld	a0,-40(s0)
    800055ce:	fffff097          	auipc	ra,0xfffff
    800055d2:	30e080e7          	jalr	782(ra) # 800048dc <filedup>
  return fd;
    800055d6:	87a6                	mv	a5,s1
}
    800055d8:	853e                	mv	a0,a5
    800055da:	70a2                	ld	ra,40(sp)
    800055dc:	7402                	ld	s0,32(sp)
    800055de:	64e2                	ld	s1,24(sp)
    800055e0:	6145                	addi	sp,sp,48
    800055e2:	8082                	ret

00000000800055e4 <sys_read>:
{
    800055e4:	7179                	addi	sp,sp,-48
    800055e6:	f406                	sd	ra,40(sp)
    800055e8:	f022                	sd	s0,32(sp)
    800055ea:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800055ec:	fe840613          	addi	a2,s0,-24
    800055f0:	4581                	li	a1,0
    800055f2:	4501                	li	a0,0
    800055f4:	00000097          	auipc	ra,0x0
    800055f8:	d8a080e7          	jalr	-630(ra) # 8000537e <argfd>
    return -1;
    800055fc:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    800055fe:	04054163          	bltz	a0,80005640 <sys_read+0x5c>
    80005602:	fe440593          	addi	a1,s0,-28
    80005606:	4509                	li	a0,2
    80005608:	ffffd097          	auipc	ra,0xffffd
    8000560c:	68c080e7          	jalr	1676(ra) # 80002c94 <argint>
    return -1;
    80005610:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005612:	02054763          	bltz	a0,80005640 <sys_read+0x5c>
    80005616:	fd840593          	addi	a1,s0,-40
    8000561a:	4505                	li	a0,1
    8000561c:	ffffd097          	auipc	ra,0xffffd
    80005620:	69a080e7          	jalr	1690(ra) # 80002cb6 <argaddr>
    return -1;
    80005624:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005626:	00054d63          	bltz	a0,80005640 <sys_read+0x5c>
  return fileread(f, p, n);
    8000562a:	fe442603          	lw	a2,-28(s0)
    8000562e:	fd843583          	ld	a1,-40(s0)
    80005632:	fe843503          	ld	a0,-24(s0)
    80005636:	fffff097          	auipc	ra,0xfffff
    8000563a:	43a080e7          	jalr	1082(ra) # 80004a70 <fileread>
    8000563e:	87aa                	mv	a5,a0
}
    80005640:	853e                	mv	a0,a5
    80005642:	70a2                	ld	ra,40(sp)
    80005644:	7402                	ld	s0,32(sp)
    80005646:	6145                	addi	sp,sp,48
    80005648:	8082                	ret

000000008000564a <sys_write>:
{
    8000564a:	7179                	addi	sp,sp,-48
    8000564c:	f406                	sd	ra,40(sp)
    8000564e:	f022                	sd	s0,32(sp)
    80005650:	1800                	addi	s0,sp,48
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005652:	fe840613          	addi	a2,s0,-24
    80005656:	4581                	li	a1,0
    80005658:	4501                	li	a0,0
    8000565a:	00000097          	auipc	ra,0x0
    8000565e:	d24080e7          	jalr	-732(ra) # 8000537e <argfd>
    return -1;
    80005662:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005664:	04054163          	bltz	a0,800056a6 <sys_write+0x5c>
    80005668:	fe440593          	addi	a1,s0,-28
    8000566c:	4509                	li	a0,2
    8000566e:	ffffd097          	auipc	ra,0xffffd
    80005672:	626080e7          	jalr	1574(ra) # 80002c94 <argint>
    return -1;
    80005676:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    80005678:	02054763          	bltz	a0,800056a6 <sys_write+0x5c>
    8000567c:	fd840593          	addi	a1,s0,-40
    80005680:	4505                	li	a0,1
    80005682:	ffffd097          	auipc	ra,0xffffd
    80005686:	634080e7          	jalr	1588(ra) # 80002cb6 <argaddr>
    return -1;
    8000568a:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
    8000568c:	00054d63          	bltz	a0,800056a6 <sys_write+0x5c>
  return filewrite(f, p, n);
    80005690:	fe442603          	lw	a2,-28(s0)
    80005694:	fd843583          	ld	a1,-40(s0)
    80005698:	fe843503          	ld	a0,-24(s0)
    8000569c:	fffff097          	auipc	ra,0xfffff
    800056a0:	49a080e7          	jalr	1178(ra) # 80004b36 <filewrite>
    800056a4:	87aa                	mv	a5,a0
}
    800056a6:	853e                	mv	a0,a5
    800056a8:	70a2                	ld	ra,40(sp)
    800056aa:	7402                	ld	s0,32(sp)
    800056ac:	6145                	addi	sp,sp,48
    800056ae:	8082                	ret

00000000800056b0 <sys_close>:
{
    800056b0:	1101                	addi	sp,sp,-32
    800056b2:	ec06                	sd	ra,24(sp)
    800056b4:	e822                	sd	s0,16(sp)
    800056b6:	1000                	addi	s0,sp,32
  if(argfd(0, &fd, &f) < 0)
    800056b8:	fe040613          	addi	a2,s0,-32
    800056bc:	fec40593          	addi	a1,s0,-20
    800056c0:	4501                	li	a0,0
    800056c2:	00000097          	auipc	ra,0x0
    800056c6:	cbc080e7          	jalr	-836(ra) # 8000537e <argfd>
    return -1;
    800056ca:	57fd                	li	a5,-1
  if(argfd(0, &fd, &f) < 0)
    800056cc:	02054463          	bltz	a0,800056f4 <sys_close+0x44>
  myproc()->ofile[fd] = 0;
    800056d0:	ffffc097          	auipc	ra,0xffffc
    800056d4:	536080e7          	jalr	1334(ra) # 80001c06 <myproc>
    800056d8:	fec42783          	lw	a5,-20(s0)
    800056dc:	07e9                	addi	a5,a5,26
    800056de:	078e                	slli	a5,a5,0x3
    800056e0:	953e                	add	a0,a0,a5
    800056e2:	00053423          	sd	zero,8(a0)
  fileclose(f);
    800056e6:	fe043503          	ld	a0,-32(s0)
    800056ea:	fffff097          	auipc	ra,0xfffff
    800056ee:	244080e7          	jalr	580(ra) # 8000492e <fileclose>
  return 0;
    800056f2:	4781                	li	a5,0
}
    800056f4:	853e                	mv	a0,a5
    800056f6:	60e2                	ld	ra,24(sp)
    800056f8:	6442                	ld	s0,16(sp)
    800056fa:	6105                	addi	sp,sp,32
    800056fc:	8082                	ret

00000000800056fe <sys_fstat>:
{
    800056fe:	1101                	addi	sp,sp,-32
    80005700:	ec06                	sd	ra,24(sp)
    80005702:	e822                	sd	s0,16(sp)
    80005704:	1000                	addi	s0,sp,32
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    80005706:	fe840613          	addi	a2,s0,-24
    8000570a:	4581                	li	a1,0
    8000570c:	4501                	li	a0,0
    8000570e:	00000097          	auipc	ra,0x0
    80005712:	c70080e7          	jalr	-912(ra) # 8000537e <argfd>
    return -1;
    80005716:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    80005718:	02054563          	bltz	a0,80005742 <sys_fstat+0x44>
    8000571c:	fe040593          	addi	a1,s0,-32
    80005720:	4505                	li	a0,1
    80005722:	ffffd097          	auipc	ra,0xffffd
    80005726:	594080e7          	jalr	1428(ra) # 80002cb6 <argaddr>
    return -1;
    8000572a:	57fd                	li	a5,-1
  if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
    8000572c:	00054b63          	bltz	a0,80005742 <sys_fstat+0x44>
  return filestat(f, st);
    80005730:	fe043583          	ld	a1,-32(s0)
    80005734:	fe843503          	ld	a0,-24(s0)
    80005738:	fffff097          	auipc	ra,0xfffff
    8000573c:	2c6080e7          	jalr	710(ra) # 800049fe <filestat>
    80005740:	87aa                	mv	a5,a0
}
    80005742:	853e                	mv	a0,a5
    80005744:	60e2                	ld	ra,24(sp)
    80005746:	6442                	ld	s0,16(sp)
    80005748:	6105                	addi	sp,sp,32
    8000574a:	8082                	ret

000000008000574c <sys_link>:
{
    8000574c:	7169                	addi	sp,sp,-304
    8000574e:	f606                	sd	ra,296(sp)
    80005750:	f222                	sd	s0,288(sp)
    80005752:	ee26                	sd	s1,280(sp)
    80005754:	ea4a                	sd	s2,272(sp)
    80005756:	1a00                	addi	s0,sp,304
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    80005758:	08000613          	li	a2,128
    8000575c:	ed040593          	addi	a1,s0,-304
    80005760:	4501                	li	a0,0
    80005762:	ffffd097          	auipc	ra,0xffffd
    80005766:	576080e7          	jalr	1398(ra) # 80002cd8 <argstr>
    return -1;
    8000576a:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    8000576c:	12054363          	bltz	a0,80005892 <sys_link+0x146>
    80005770:	08000613          	li	a2,128
    80005774:	f5040593          	addi	a1,s0,-176
    80005778:	4505                	li	a0,1
    8000577a:	ffffd097          	auipc	ra,0xffffd
    8000577e:	55e080e7          	jalr	1374(ra) # 80002cd8 <argstr>
    return -1;
    80005782:	57fd                	li	a5,-1
  if(argstr(0, old, MAXPATH) < 0 || argstr(1, new, MAXPATH) < 0)
    80005784:	10054763          	bltz	a0,80005892 <sys_link+0x146>
  begin_op(ROOTDEV);
    80005788:	4501                	li	a0,0
    8000578a:	fffff097          	auipc	ra,0xfffff
    8000578e:	bd8080e7          	jalr	-1064(ra) # 80004362 <begin_op>
  if((ip = namei(old)) == 0){
    80005792:	ed040513          	addi	a0,s0,-304
    80005796:	fffff097          	auipc	ra,0xfffff
    8000579a:	972080e7          	jalr	-1678(ra) # 80004108 <namei>
    8000579e:	84aa                	mv	s1,a0
    800057a0:	c559                	beqz	a0,8000582e <sys_link+0xe2>
  ilock(ip);
    800057a2:	ffffe097          	auipc	ra,0xffffe
    800057a6:	1d2080e7          	jalr	466(ra) # 80003974 <ilock>
  if(ip->type == T_DIR){
    800057aa:	04c49703          	lh	a4,76(s1)
    800057ae:	4785                	li	a5,1
    800057b0:	08f70663          	beq	a4,a5,8000583c <sys_link+0xf0>
  ip->nlink++;
    800057b4:	0524d783          	lhu	a5,82(s1)
    800057b8:	2785                	addiw	a5,a5,1
    800057ba:	04f49923          	sh	a5,82(s1)
  iupdate(ip);
    800057be:	8526                	mv	a0,s1
    800057c0:	ffffe097          	auipc	ra,0xffffe
    800057c4:	0e8080e7          	jalr	232(ra) # 800038a8 <iupdate>
  iunlock(ip);
    800057c8:	8526                	mv	a0,s1
    800057ca:	ffffe097          	auipc	ra,0xffffe
    800057ce:	26e080e7          	jalr	622(ra) # 80003a38 <iunlock>
  if((dp = nameiparent(new, name)) == 0)
    800057d2:	fd040593          	addi	a1,s0,-48
    800057d6:	f5040513          	addi	a0,s0,-176
    800057da:	fffff097          	auipc	ra,0xfffff
    800057de:	94c080e7          	jalr	-1716(ra) # 80004126 <nameiparent>
    800057e2:	892a                	mv	s2,a0
    800057e4:	cd2d                	beqz	a0,8000585e <sys_link+0x112>
  ilock(dp);
    800057e6:	ffffe097          	auipc	ra,0xffffe
    800057ea:	18e080e7          	jalr	398(ra) # 80003974 <ilock>
  if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){
    800057ee:	00092703          	lw	a4,0(s2)
    800057f2:	409c                	lw	a5,0(s1)
    800057f4:	06f71063          	bne	a4,a5,80005854 <sys_link+0x108>
    800057f8:	40d0                	lw	a2,4(s1)
    800057fa:	fd040593          	addi	a1,s0,-48
    800057fe:	854a                	mv	a0,s2
    80005800:	fffff097          	auipc	ra,0xfffff
    80005804:	846080e7          	jalr	-1978(ra) # 80004046 <dirlink>
    80005808:	04054663          	bltz	a0,80005854 <sys_link+0x108>
  iunlockput(dp);
    8000580c:	854a                	mv	a0,s2
    8000580e:	ffffe097          	auipc	ra,0xffffe
    80005812:	3a6080e7          	jalr	934(ra) # 80003bb4 <iunlockput>
  iput(ip);
    80005816:	8526                	mv	a0,s1
    80005818:	ffffe097          	auipc	ra,0xffffe
    8000581c:	26c080e7          	jalr	620(ra) # 80003a84 <iput>
  end_op(ROOTDEV);
    80005820:	4501                	li	a0,0
    80005822:	fffff097          	auipc	ra,0xfffff
    80005826:	bea080e7          	jalr	-1046(ra) # 8000440c <end_op>
  return 0;
    8000582a:	4781                	li	a5,0
    8000582c:	a09d                	j	80005892 <sys_link+0x146>
    end_op(ROOTDEV);
    8000582e:	4501                	li	a0,0
    80005830:	fffff097          	auipc	ra,0xfffff
    80005834:	bdc080e7          	jalr	-1060(ra) # 8000440c <end_op>
    return -1;
    80005838:	57fd                	li	a5,-1
    8000583a:	a8a1                	j	80005892 <sys_link+0x146>
    iunlockput(ip);
    8000583c:	8526                	mv	a0,s1
    8000583e:	ffffe097          	auipc	ra,0xffffe
    80005842:	376080e7          	jalr	886(ra) # 80003bb4 <iunlockput>
    end_op(ROOTDEV);
    80005846:	4501                	li	a0,0
    80005848:	fffff097          	auipc	ra,0xfffff
    8000584c:	bc4080e7          	jalr	-1084(ra) # 8000440c <end_op>
    return -1;
    80005850:	57fd                	li	a5,-1
    80005852:	a081                	j	80005892 <sys_link+0x146>
    iunlockput(dp);
    80005854:	854a                	mv	a0,s2
    80005856:	ffffe097          	auipc	ra,0xffffe
    8000585a:	35e080e7          	jalr	862(ra) # 80003bb4 <iunlockput>
  ilock(ip);
    8000585e:	8526                	mv	a0,s1
    80005860:	ffffe097          	auipc	ra,0xffffe
    80005864:	114080e7          	jalr	276(ra) # 80003974 <ilock>
  ip->nlink--;
    80005868:	0524d783          	lhu	a5,82(s1)
    8000586c:	37fd                	addiw	a5,a5,-1
    8000586e:	04f49923          	sh	a5,82(s1)
  iupdate(ip);
    80005872:	8526                	mv	a0,s1
    80005874:	ffffe097          	auipc	ra,0xffffe
    80005878:	034080e7          	jalr	52(ra) # 800038a8 <iupdate>
  iunlockput(ip);
    8000587c:	8526                	mv	a0,s1
    8000587e:	ffffe097          	auipc	ra,0xffffe
    80005882:	336080e7          	jalr	822(ra) # 80003bb4 <iunlockput>
  end_op(ROOTDEV);
    80005886:	4501                	li	a0,0
    80005888:	fffff097          	auipc	ra,0xfffff
    8000588c:	b84080e7          	jalr	-1148(ra) # 8000440c <end_op>
  return -1;
    80005890:	57fd                	li	a5,-1
}
    80005892:	853e                	mv	a0,a5
    80005894:	70b2                	ld	ra,296(sp)
    80005896:	7412                	ld	s0,288(sp)
    80005898:	64f2                	ld	s1,280(sp)
    8000589a:	6952                	ld	s2,272(sp)
    8000589c:	6155                	addi	sp,sp,304
    8000589e:	8082                	ret

00000000800058a0 <sys_unlink>:
{
    800058a0:	7151                	addi	sp,sp,-240
    800058a2:	f586                	sd	ra,232(sp)
    800058a4:	f1a2                	sd	s0,224(sp)
    800058a6:	eda6                	sd	s1,216(sp)
    800058a8:	e9ca                	sd	s2,208(sp)
    800058aa:	e5ce                	sd	s3,200(sp)
    800058ac:	1980                	addi	s0,sp,240
  if(argstr(0, path, MAXPATH) < 0)
    800058ae:	08000613          	li	a2,128
    800058b2:	f3040593          	addi	a1,s0,-208
    800058b6:	4501                	li	a0,0
    800058b8:	ffffd097          	auipc	ra,0xffffd
    800058bc:	420080e7          	jalr	1056(ra) # 80002cd8 <argstr>
    800058c0:	18054263          	bltz	a0,80005a44 <sys_unlink+0x1a4>
  begin_op(ROOTDEV);
    800058c4:	4501                	li	a0,0
    800058c6:	fffff097          	auipc	ra,0xfffff
    800058ca:	a9c080e7          	jalr	-1380(ra) # 80004362 <begin_op>
  if((dp = nameiparent(path, name)) == 0){
    800058ce:	fb040593          	addi	a1,s0,-80
    800058d2:	f3040513          	addi	a0,s0,-208
    800058d6:	fffff097          	auipc	ra,0xfffff
    800058da:	850080e7          	jalr	-1968(ra) # 80004126 <nameiparent>
    800058de:	89aa                	mv	s3,a0
    800058e0:	cd61                	beqz	a0,800059b8 <sys_unlink+0x118>
  ilock(dp);
    800058e2:	ffffe097          	auipc	ra,0xffffe
    800058e6:	092080e7          	jalr	146(ra) # 80003974 <ilock>
  if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0)
    800058ea:	00003597          	auipc	a1,0x3
    800058ee:	f4e58593          	addi	a1,a1,-178 # 80008838 <userret+0x7a8>
    800058f2:	fb040513          	addi	a0,s0,-80
    800058f6:	ffffe097          	auipc	ra,0xffffe
    800058fa:	51e080e7          	jalr	1310(ra) # 80003e14 <namecmp>
    800058fe:	14050a63          	beqz	a0,80005a52 <sys_unlink+0x1b2>
    80005902:	00003597          	auipc	a1,0x3
    80005906:	f3e58593          	addi	a1,a1,-194 # 80008840 <userret+0x7b0>
    8000590a:	fb040513          	addi	a0,s0,-80
    8000590e:	ffffe097          	auipc	ra,0xffffe
    80005912:	506080e7          	jalr	1286(ra) # 80003e14 <namecmp>
    80005916:	12050e63          	beqz	a0,80005a52 <sys_unlink+0x1b2>
  if((ip = dirlookup(dp, name, &off)) == 0)
    8000591a:	f2c40613          	addi	a2,s0,-212
    8000591e:	fb040593          	addi	a1,s0,-80
    80005922:	854e                	mv	a0,s3
    80005924:	ffffe097          	auipc	ra,0xffffe
    80005928:	50a080e7          	jalr	1290(ra) # 80003e2e <dirlookup>
    8000592c:	84aa                	mv	s1,a0
    8000592e:	12050263          	beqz	a0,80005a52 <sys_unlink+0x1b2>
  ilock(ip);
    80005932:	ffffe097          	auipc	ra,0xffffe
    80005936:	042080e7          	jalr	66(ra) # 80003974 <ilock>
  if(ip->nlink < 1)
    8000593a:	05249783          	lh	a5,82(s1)
    8000593e:	08f05463          	blez	a5,800059c6 <sys_unlink+0x126>
  if(ip->type == T_DIR && !isdirempty(ip)){
    80005942:	04c49703          	lh	a4,76(s1)
    80005946:	4785                	li	a5,1
    80005948:	08f70763          	beq	a4,a5,800059d6 <sys_unlink+0x136>
  memset(&de, 0, sizeof(de));
    8000594c:	4641                	li	a2,16
    8000594e:	4581                	li	a1,0
    80005950:	fc040513          	addi	a0,s0,-64
    80005954:	ffffb097          	auipc	ra,0xffffb
    80005958:	588080e7          	jalr	1416(ra) # 80000edc <memset>
  if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    8000595c:	4741                	li	a4,16
    8000595e:	f2c42683          	lw	a3,-212(s0)
    80005962:	fc040613          	addi	a2,s0,-64
    80005966:	4581                	li	a1,0
    80005968:	854e                	mv	a0,s3
    8000596a:	ffffe097          	auipc	ra,0xffffe
    8000596e:	390080e7          	jalr	912(ra) # 80003cfa <writei>
    80005972:	47c1                	li	a5,16
    80005974:	0af51563          	bne	a0,a5,80005a1e <sys_unlink+0x17e>
  if(ip->type == T_DIR){
    80005978:	04c49703          	lh	a4,76(s1)
    8000597c:	4785                	li	a5,1
    8000597e:	0af70863          	beq	a4,a5,80005a2e <sys_unlink+0x18e>
  iunlockput(dp);
    80005982:	854e                	mv	a0,s3
    80005984:	ffffe097          	auipc	ra,0xffffe
    80005988:	230080e7          	jalr	560(ra) # 80003bb4 <iunlockput>
  ip->nlink--;
    8000598c:	0524d783          	lhu	a5,82(s1)
    80005990:	37fd                	addiw	a5,a5,-1
    80005992:	04f49923          	sh	a5,82(s1)
  iupdate(ip);
    80005996:	8526                	mv	a0,s1
    80005998:	ffffe097          	auipc	ra,0xffffe
    8000599c:	f10080e7          	jalr	-240(ra) # 800038a8 <iupdate>
  iunlockput(ip);
    800059a0:	8526                	mv	a0,s1
    800059a2:	ffffe097          	auipc	ra,0xffffe
    800059a6:	212080e7          	jalr	530(ra) # 80003bb4 <iunlockput>
  end_op(ROOTDEV);
    800059aa:	4501                	li	a0,0
    800059ac:	fffff097          	auipc	ra,0xfffff
    800059b0:	a60080e7          	jalr	-1440(ra) # 8000440c <end_op>
  return 0;
    800059b4:	4501                	li	a0,0
    800059b6:	a84d                	j	80005a68 <sys_unlink+0x1c8>
    end_op(ROOTDEV);
    800059b8:	4501                	li	a0,0
    800059ba:	fffff097          	auipc	ra,0xfffff
    800059be:	a52080e7          	jalr	-1454(ra) # 8000440c <end_op>
    return -1;
    800059c2:	557d                	li	a0,-1
    800059c4:	a055                	j	80005a68 <sys_unlink+0x1c8>
    panic("unlink: nlink < 1");
    800059c6:	00003517          	auipc	a0,0x3
    800059ca:	ea250513          	addi	a0,a0,-350 # 80008868 <userret+0x7d8>
    800059ce:	ffffb097          	auipc	ra,0xffffb
    800059d2:	bb0080e7          	jalr	-1104(ra) # 8000057e <panic>
  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
    800059d6:	48f8                	lw	a4,84(s1)
    800059d8:	02000793          	li	a5,32
    800059dc:	f6e7f8e3          	bleu	a4,a5,8000594c <sys_unlink+0xac>
    800059e0:	02000913          	li	s2,32
    if(readi(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
    800059e4:	4741                	li	a4,16
    800059e6:	86ca                	mv	a3,s2
    800059e8:	f1840613          	addi	a2,s0,-232
    800059ec:	4581                	li	a1,0
    800059ee:	8526                	mv	a0,s1
    800059f0:	ffffe097          	auipc	ra,0xffffe
    800059f4:	216080e7          	jalr	534(ra) # 80003c06 <readi>
    800059f8:	47c1                	li	a5,16
    800059fa:	00f51a63          	bne	a0,a5,80005a0e <sys_unlink+0x16e>
    if(de.inum != 0)
    800059fe:	f1845783          	lhu	a5,-232(s0)
    80005a02:	e3b9                	bnez	a5,80005a48 <sys_unlink+0x1a8>
  for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){
    80005a04:	2941                	addiw	s2,s2,16
    80005a06:	48fc                	lw	a5,84(s1)
    80005a08:	fcf96ee3          	bltu	s2,a5,800059e4 <sys_unlink+0x144>
    80005a0c:	b781                	j	8000594c <sys_unlink+0xac>
      panic("isdirempty: readi");
    80005a0e:	00003517          	auipc	a0,0x3
    80005a12:	e7250513          	addi	a0,a0,-398 # 80008880 <userret+0x7f0>
    80005a16:	ffffb097          	auipc	ra,0xffffb
    80005a1a:	b68080e7          	jalr	-1176(ra) # 8000057e <panic>
    panic("unlink: writei");
    80005a1e:	00003517          	auipc	a0,0x3
    80005a22:	e7a50513          	addi	a0,a0,-390 # 80008898 <userret+0x808>
    80005a26:	ffffb097          	auipc	ra,0xffffb
    80005a2a:	b58080e7          	jalr	-1192(ra) # 8000057e <panic>
    dp->nlink--;
    80005a2e:	0529d783          	lhu	a5,82(s3)
    80005a32:	37fd                	addiw	a5,a5,-1
    80005a34:	04f99923          	sh	a5,82(s3)
    iupdate(dp);
    80005a38:	854e                	mv	a0,s3
    80005a3a:	ffffe097          	auipc	ra,0xffffe
    80005a3e:	e6e080e7          	jalr	-402(ra) # 800038a8 <iupdate>
    80005a42:	b781                	j	80005982 <sys_unlink+0xe2>
    return -1;
    80005a44:	557d                	li	a0,-1
    80005a46:	a00d                	j	80005a68 <sys_unlink+0x1c8>
    iunlockput(ip);
    80005a48:	8526                	mv	a0,s1
    80005a4a:	ffffe097          	auipc	ra,0xffffe
    80005a4e:	16a080e7          	jalr	362(ra) # 80003bb4 <iunlockput>
  iunlockput(dp);
    80005a52:	854e                	mv	a0,s3
    80005a54:	ffffe097          	auipc	ra,0xffffe
    80005a58:	160080e7          	jalr	352(ra) # 80003bb4 <iunlockput>
  end_op(ROOTDEV);
    80005a5c:	4501                	li	a0,0
    80005a5e:	fffff097          	auipc	ra,0xfffff
    80005a62:	9ae080e7          	jalr	-1618(ra) # 8000440c <end_op>
  return -1;
    80005a66:	557d                	li	a0,-1
}
    80005a68:	70ae                	ld	ra,232(sp)
    80005a6a:	740e                	ld	s0,224(sp)
    80005a6c:	64ee                	ld	s1,216(sp)
    80005a6e:	694e                	ld	s2,208(sp)
    80005a70:	69ae                	ld	s3,200(sp)
    80005a72:	616d                	addi	sp,sp,240
    80005a74:	8082                	ret

0000000080005a76 <sys_open>:

uint64
sys_open(void)
{
    80005a76:	7131                	addi	sp,sp,-192
    80005a78:	fd06                	sd	ra,184(sp)
    80005a7a:	f922                	sd	s0,176(sp)
    80005a7c:	f526                	sd	s1,168(sp)
    80005a7e:	f14a                	sd	s2,160(sp)
    80005a80:	ed4e                	sd	s3,152(sp)
    80005a82:	0180                	addi	s0,sp,192
  int fd, omode;
  struct file *f;
  struct inode *ip;
  int n;

  if((n = argstr(0, path, MAXPATH)) < 0 || argint(1, &omode) < 0)
    80005a84:	08000613          	li	a2,128
    80005a88:	f5040593          	addi	a1,s0,-176
    80005a8c:	4501                	li	a0,0
    80005a8e:	ffffd097          	auipc	ra,0xffffd
    80005a92:	24a080e7          	jalr	586(ra) # 80002cd8 <argstr>
    return -1;
    80005a96:	54fd                	li	s1,-1
  if((n = argstr(0, path, MAXPATH)) < 0 || argint(1, &omode) < 0)
    80005a98:	0a054963          	bltz	a0,80005b4a <sys_open+0xd4>
    80005a9c:	f4c40593          	addi	a1,s0,-180
    80005aa0:	4505                	li	a0,1
    80005aa2:	ffffd097          	auipc	ra,0xffffd
    80005aa6:	1f2080e7          	jalr	498(ra) # 80002c94 <argint>
    80005aaa:	0a054063          	bltz	a0,80005b4a <sys_open+0xd4>

  begin_op(ROOTDEV);
    80005aae:	4501                	li	a0,0
    80005ab0:	fffff097          	auipc	ra,0xfffff
    80005ab4:	8b2080e7          	jalr	-1870(ra) # 80004362 <begin_op>

  if(omode & O_CREATE){
    80005ab8:	f4c42783          	lw	a5,-180(s0)
    80005abc:	2007f793          	andi	a5,a5,512
    80005ac0:	c3dd                	beqz	a5,80005b66 <sys_open+0xf0>
    ip = create(path, T_FILE, 0, 0);
    80005ac2:	4681                	li	a3,0
    80005ac4:	4601                	li	a2,0
    80005ac6:	4589                	li	a1,2
    80005ac8:	f5040513          	addi	a0,s0,-176
    80005acc:	00000097          	auipc	ra,0x0
    80005ad0:	962080e7          	jalr	-1694(ra) # 8000542e <create>
    80005ad4:	892a                	mv	s2,a0
    if(ip == 0){
    80005ad6:	c151                	beqz	a0,80005b5a <sys_open+0xe4>
      end_op(ROOTDEV);
      return -1;
    }
  }

  if(ip->type == T_DEVICE && (ip->major < 0 || ip->major >= NDEV)){
    80005ad8:	04c91703          	lh	a4,76(s2)
    80005adc:	478d                	li	a5,3
    80005ade:	00f71763          	bne	a4,a5,80005aec <sys_open+0x76>
    80005ae2:	04e95703          	lhu	a4,78(s2)
    80005ae6:	47a5                	li	a5,9
    80005ae8:	0ce7e663          	bltu	a5,a4,80005bb4 <sys_open+0x13e>
    iunlockput(ip);
    end_op(ROOTDEV);
    return -1;
  }

  if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){
    80005aec:	fffff097          	auipc	ra,0xfffff
    80005af0:	d72080e7          	jalr	-654(ra) # 8000485e <filealloc>
    80005af4:	89aa                	mv	s3,a0
    80005af6:	c97d                	beqz	a0,80005bec <sys_open+0x176>
    80005af8:	00000097          	auipc	ra,0x0
    80005afc:	8ee080e7          	jalr	-1810(ra) # 800053e6 <fdalloc>
    80005b00:	84aa                	mv	s1,a0
    80005b02:	0e054063          	bltz	a0,80005be2 <sys_open+0x16c>
    iunlockput(ip);
    end_op(ROOTDEV);
    return -1;
  }

  if(ip->type == T_DEVICE){
    80005b06:	04c91703          	lh	a4,76(s2)
    80005b0a:	478d                	li	a5,3
    80005b0c:	0cf70063          	beq	a4,a5,80005bcc <sys_open+0x156>
    f->type = FD_DEVICE;
    f->major = ip->major;
    f->minor = ip->minor;
  } else {
    f->type = FD_INODE;
    80005b10:	4789                	li	a5,2
    80005b12:	00f9a023          	sw	a5,0(s3)
  }
  f->ip = ip;
    80005b16:	0129bc23          	sd	s2,24(s3)
  f->off = 0;
    80005b1a:	0209a023          	sw	zero,32(s3)
  f->readable = !(omode & O_WRONLY);
    80005b1e:	f4c42783          	lw	a5,-180(s0)
    80005b22:	0017c713          	xori	a4,a5,1
    80005b26:	8b05                	andi	a4,a4,1
    80005b28:	00e98423          	sb	a4,8(s3)
  f->writable = (omode & O_WRONLY) || (omode & O_RDWR);
    80005b2c:	8b8d                	andi	a5,a5,3
    80005b2e:	00f037b3          	snez	a5,a5
    80005b32:	00f984a3          	sb	a5,9(s3)

  iunlock(ip);
    80005b36:	854a                	mv	a0,s2
    80005b38:	ffffe097          	auipc	ra,0xffffe
    80005b3c:	f00080e7          	jalr	-256(ra) # 80003a38 <iunlock>
  end_op(ROOTDEV);
    80005b40:	4501                	li	a0,0
    80005b42:	fffff097          	auipc	ra,0xfffff
    80005b46:	8ca080e7          	jalr	-1846(ra) # 8000440c <end_op>

  return fd;
}
    80005b4a:	8526                	mv	a0,s1
    80005b4c:	70ea                	ld	ra,184(sp)
    80005b4e:	744a                	ld	s0,176(sp)
    80005b50:	74aa                	ld	s1,168(sp)
    80005b52:	790a                	ld	s2,160(sp)
    80005b54:	69ea                	ld	s3,152(sp)
    80005b56:	6129                	addi	sp,sp,192
    80005b58:	8082                	ret
      end_op(ROOTDEV);
    80005b5a:	4501                	li	a0,0
    80005b5c:	fffff097          	auipc	ra,0xfffff
    80005b60:	8b0080e7          	jalr	-1872(ra) # 8000440c <end_op>
      return -1;
    80005b64:	b7dd                	j	80005b4a <sys_open+0xd4>
    if((ip = namei(path)) == 0){
    80005b66:	f5040513          	addi	a0,s0,-176
    80005b6a:	ffffe097          	auipc	ra,0xffffe
    80005b6e:	59e080e7          	jalr	1438(ra) # 80004108 <namei>
    80005b72:	892a                	mv	s2,a0
    80005b74:	c90d                	beqz	a0,80005ba6 <sys_open+0x130>
    ilock(ip);
    80005b76:	ffffe097          	auipc	ra,0xffffe
    80005b7a:	dfe080e7          	jalr	-514(ra) # 80003974 <ilock>
    if(ip->type == T_DIR && omode != O_RDONLY){
    80005b7e:	04c91703          	lh	a4,76(s2)
    80005b82:	4785                	li	a5,1
    80005b84:	f4f71ae3          	bne	a4,a5,80005ad8 <sys_open+0x62>
    80005b88:	f4c42783          	lw	a5,-180(s0)
    80005b8c:	d3a5                	beqz	a5,80005aec <sys_open+0x76>
      iunlockput(ip);
    80005b8e:	854a                	mv	a0,s2
    80005b90:	ffffe097          	auipc	ra,0xffffe
    80005b94:	024080e7          	jalr	36(ra) # 80003bb4 <iunlockput>
      end_op(ROOTDEV);
    80005b98:	4501                	li	a0,0
    80005b9a:	fffff097          	auipc	ra,0xfffff
    80005b9e:	872080e7          	jalr	-1934(ra) # 8000440c <end_op>
      return -1;
    80005ba2:	54fd                	li	s1,-1
    80005ba4:	b75d                	j	80005b4a <sys_open+0xd4>
      end_op(ROOTDEV);
    80005ba6:	4501                	li	a0,0
    80005ba8:	fffff097          	auipc	ra,0xfffff
    80005bac:	864080e7          	jalr	-1948(ra) # 8000440c <end_op>
      return -1;
    80005bb0:	54fd                	li	s1,-1
    80005bb2:	bf61                	j	80005b4a <sys_open+0xd4>
    iunlockput(ip);
    80005bb4:	854a                	mv	a0,s2
    80005bb6:	ffffe097          	auipc	ra,0xffffe
    80005bba:	ffe080e7          	jalr	-2(ra) # 80003bb4 <iunlockput>
    end_op(ROOTDEV);
    80005bbe:	4501                	li	a0,0
    80005bc0:	fffff097          	auipc	ra,0xfffff
    80005bc4:	84c080e7          	jalr	-1972(ra) # 8000440c <end_op>
    return -1;
    80005bc8:	54fd                	li	s1,-1
    80005bca:	b741                	j	80005b4a <sys_open+0xd4>
    f->type = FD_DEVICE;
    80005bcc:	00f9a023          	sw	a5,0(s3)
    f->major = ip->major;
    80005bd0:	04e91783          	lh	a5,78(s2)
    80005bd4:	02f99223          	sh	a5,36(s3)
    f->minor = ip->minor;
    80005bd8:	05091783          	lh	a5,80(s2)
    80005bdc:	02f99323          	sh	a5,38(s3)
    80005be0:	bf1d                	j	80005b16 <sys_open+0xa0>
      fileclose(f);
    80005be2:	854e                	mv	a0,s3
    80005be4:	fffff097          	auipc	ra,0xfffff
    80005be8:	d4a080e7          	jalr	-694(ra) # 8000492e <fileclose>
    iunlockput(ip);
    80005bec:	854a                	mv	a0,s2
    80005bee:	ffffe097          	auipc	ra,0xffffe
    80005bf2:	fc6080e7          	jalr	-58(ra) # 80003bb4 <iunlockput>
    end_op(ROOTDEV);
    80005bf6:	4501                	li	a0,0
    80005bf8:	fffff097          	auipc	ra,0xfffff
    80005bfc:	814080e7          	jalr	-2028(ra) # 8000440c <end_op>
    return -1;
    80005c00:	54fd                	li	s1,-1
    80005c02:	b7a1                	j	80005b4a <sys_open+0xd4>

0000000080005c04 <sys_mkdir>:

uint64
sys_mkdir(void)
{
    80005c04:	7175                	addi	sp,sp,-144
    80005c06:	e506                	sd	ra,136(sp)
    80005c08:	e122                	sd	s0,128(sp)
    80005c0a:	0900                	addi	s0,sp,144
  char path[MAXPATH];
  struct inode *ip;

  begin_op(ROOTDEV);
    80005c0c:	4501                	li	a0,0
    80005c0e:	ffffe097          	auipc	ra,0xffffe
    80005c12:	754080e7          	jalr	1876(ra) # 80004362 <begin_op>
  if(argstr(0, path, MAXPATH) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){
    80005c16:	08000613          	li	a2,128
    80005c1a:	f7040593          	addi	a1,s0,-144
    80005c1e:	4501                	li	a0,0
    80005c20:	ffffd097          	auipc	ra,0xffffd
    80005c24:	0b8080e7          	jalr	184(ra) # 80002cd8 <argstr>
    80005c28:	02054a63          	bltz	a0,80005c5c <sys_mkdir+0x58>
    80005c2c:	4681                	li	a3,0
    80005c2e:	4601                	li	a2,0
    80005c30:	4585                	li	a1,1
    80005c32:	f7040513          	addi	a0,s0,-144
    80005c36:	fffff097          	auipc	ra,0xfffff
    80005c3a:	7f8080e7          	jalr	2040(ra) # 8000542e <create>
    80005c3e:	cd19                	beqz	a0,80005c5c <sys_mkdir+0x58>
    end_op(ROOTDEV);
    return -1;
  }
  iunlockput(ip);
    80005c40:	ffffe097          	auipc	ra,0xffffe
    80005c44:	f74080e7          	jalr	-140(ra) # 80003bb4 <iunlockput>
  end_op(ROOTDEV);
    80005c48:	4501                	li	a0,0
    80005c4a:	ffffe097          	auipc	ra,0xffffe
    80005c4e:	7c2080e7          	jalr	1986(ra) # 8000440c <end_op>
  return 0;
    80005c52:	4501                	li	a0,0
}
    80005c54:	60aa                	ld	ra,136(sp)
    80005c56:	640a                	ld	s0,128(sp)
    80005c58:	6149                	addi	sp,sp,144
    80005c5a:	8082                	ret
    end_op(ROOTDEV);
    80005c5c:	4501                	li	a0,0
    80005c5e:	ffffe097          	auipc	ra,0xffffe
    80005c62:	7ae080e7          	jalr	1966(ra) # 8000440c <end_op>
    return -1;
    80005c66:	557d                	li	a0,-1
    80005c68:	b7f5                	j	80005c54 <sys_mkdir+0x50>

0000000080005c6a <sys_mknod>:

uint64
sys_mknod(void)
{
    80005c6a:	7135                	addi	sp,sp,-160
    80005c6c:	ed06                	sd	ra,152(sp)
    80005c6e:	e922                	sd	s0,144(sp)
    80005c70:	1100                	addi	s0,sp,160
  struct inode *ip;
  char path[MAXPATH];
  int major, minor;

  begin_op(ROOTDEV);
    80005c72:	4501                	li	a0,0
    80005c74:	ffffe097          	auipc	ra,0xffffe
    80005c78:	6ee080e7          	jalr	1774(ra) # 80004362 <begin_op>
  if((argstr(0, path, MAXPATH)) < 0 ||
    80005c7c:	08000613          	li	a2,128
    80005c80:	f7040593          	addi	a1,s0,-144
    80005c84:	4501                	li	a0,0
    80005c86:	ffffd097          	auipc	ra,0xffffd
    80005c8a:	052080e7          	jalr	82(ra) # 80002cd8 <argstr>
    80005c8e:	04054b63          	bltz	a0,80005ce4 <sys_mknod+0x7a>
     argint(1, &major) < 0 ||
    80005c92:	f6c40593          	addi	a1,s0,-148
    80005c96:	4505                	li	a0,1
    80005c98:	ffffd097          	auipc	ra,0xffffd
    80005c9c:	ffc080e7          	jalr	-4(ra) # 80002c94 <argint>
  if((argstr(0, path, MAXPATH)) < 0 ||
    80005ca0:	04054263          	bltz	a0,80005ce4 <sys_mknod+0x7a>
     argint(2, &minor) < 0 ||
    80005ca4:	f6840593          	addi	a1,s0,-152
    80005ca8:	4509                	li	a0,2
    80005caa:	ffffd097          	auipc	ra,0xffffd
    80005cae:	fea080e7          	jalr	-22(ra) # 80002c94 <argint>
     argint(1, &major) < 0 ||
    80005cb2:	02054963          	bltz	a0,80005ce4 <sys_mknod+0x7a>
     (ip = create(path, T_DEVICE, major, minor)) == 0){
    80005cb6:	f6841683          	lh	a3,-152(s0)
    80005cba:	f6c41603          	lh	a2,-148(s0)
    80005cbe:	458d                	li	a1,3
    80005cc0:	f7040513          	addi	a0,s0,-144
    80005cc4:	fffff097          	auipc	ra,0xfffff
    80005cc8:	76a080e7          	jalr	1898(ra) # 8000542e <create>
     argint(2, &minor) < 0 ||
    80005ccc:	cd01                	beqz	a0,80005ce4 <sys_mknod+0x7a>
    end_op(ROOTDEV);
    return -1;
  }
  iunlockput(ip);
    80005cce:	ffffe097          	auipc	ra,0xffffe
    80005cd2:	ee6080e7          	jalr	-282(ra) # 80003bb4 <iunlockput>
  end_op(ROOTDEV);
    80005cd6:	4501                	li	a0,0
    80005cd8:	ffffe097          	auipc	ra,0xffffe
    80005cdc:	734080e7          	jalr	1844(ra) # 8000440c <end_op>
  return 0;
    80005ce0:	4501                	li	a0,0
    80005ce2:	a039                	j	80005cf0 <sys_mknod+0x86>
    end_op(ROOTDEV);
    80005ce4:	4501                	li	a0,0
    80005ce6:	ffffe097          	auipc	ra,0xffffe
    80005cea:	726080e7          	jalr	1830(ra) # 8000440c <end_op>
    return -1;
    80005cee:	557d                	li	a0,-1
}
    80005cf0:	60ea                	ld	ra,152(sp)
    80005cf2:	644a                	ld	s0,144(sp)
    80005cf4:	610d                	addi	sp,sp,160
    80005cf6:	8082                	ret

0000000080005cf8 <sys_chdir>:

uint64
sys_chdir(void)
{
    80005cf8:	7135                	addi	sp,sp,-160
    80005cfa:	ed06                	sd	ra,152(sp)
    80005cfc:	e922                	sd	s0,144(sp)
    80005cfe:	e526                	sd	s1,136(sp)
    80005d00:	e14a                	sd	s2,128(sp)
    80005d02:	1100                	addi	s0,sp,160
  char path[MAXPATH];
  struct inode *ip;
  struct proc *p = myproc();
    80005d04:	ffffc097          	auipc	ra,0xffffc
    80005d08:	f02080e7          	jalr	-254(ra) # 80001c06 <myproc>
    80005d0c:	892a                	mv	s2,a0
  
  begin_op(ROOTDEV);
    80005d0e:	4501                	li	a0,0
    80005d10:	ffffe097          	auipc	ra,0xffffe
    80005d14:	652080e7          	jalr	1618(ra) # 80004362 <begin_op>
  if(argstr(0, path, MAXPATH) < 0 || (ip = namei(path)) == 0){
    80005d18:	08000613          	li	a2,128
    80005d1c:	f6040593          	addi	a1,s0,-160
    80005d20:	4501                	li	a0,0
    80005d22:	ffffd097          	auipc	ra,0xffffd
    80005d26:	fb6080e7          	jalr	-74(ra) # 80002cd8 <argstr>
    80005d2a:	04054c63          	bltz	a0,80005d82 <sys_chdir+0x8a>
    80005d2e:	f6040513          	addi	a0,s0,-160
    80005d32:	ffffe097          	auipc	ra,0xffffe
    80005d36:	3d6080e7          	jalr	982(ra) # 80004108 <namei>
    80005d3a:	84aa                	mv	s1,a0
    80005d3c:	c139                	beqz	a0,80005d82 <sys_chdir+0x8a>
    end_op(ROOTDEV);
    return -1;
  }
  ilock(ip);
    80005d3e:	ffffe097          	auipc	ra,0xffffe
    80005d42:	c36080e7          	jalr	-970(ra) # 80003974 <ilock>
  if(ip->type != T_DIR){
    80005d46:	04c49703          	lh	a4,76(s1)
    80005d4a:	4785                	li	a5,1
    80005d4c:	04f71263          	bne	a4,a5,80005d90 <sys_chdir+0x98>
    iunlockput(ip);
    end_op(ROOTDEV);
    return -1;
  }
  iunlock(ip);
    80005d50:	8526                	mv	a0,s1
    80005d52:	ffffe097          	auipc	ra,0xffffe
    80005d56:	ce6080e7          	jalr	-794(ra) # 80003a38 <iunlock>
  iput(p->cwd);
    80005d5a:	15893503          	ld	a0,344(s2)
    80005d5e:	ffffe097          	auipc	ra,0xffffe
    80005d62:	d26080e7          	jalr	-730(ra) # 80003a84 <iput>
  end_op(ROOTDEV);
    80005d66:	4501                	li	a0,0
    80005d68:	ffffe097          	auipc	ra,0xffffe
    80005d6c:	6a4080e7          	jalr	1700(ra) # 8000440c <end_op>
  p->cwd = ip;
    80005d70:	14993c23          	sd	s1,344(s2)
  return 0;
    80005d74:	4501                	li	a0,0
}
    80005d76:	60ea                	ld	ra,152(sp)
    80005d78:	644a                	ld	s0,144(sp)
    80005d7a:	64aa                	ld	s1,136(sp)
    80005d7c:	690a                	ld	s2,128(sp)
    80005d7e:	610d                	addi	sp,sp,160
    80005d80:	8082                	ret
    end_op(ROOTDEV);
    80005d82:	4501                	li	a0,0
    80005d84:	ffffe097          	auipc	ra,0xffffe
    80005d88:	688080e7          	jalr	1672(ra) # 8000440c <end_op>
    return -1;
    80005d8c:	557d                	li	a0,-1
    80005d8e:	b7e5                	j	80005d76 <sys_chdir+0x7e>
    iunlockput(ip);
    80005d90:	8526                	mv	a0,s1
    80005d92:	ffffe097          	auipc	ra,0xffffe
    80005d96:	e22080e7          	jalr	-478(ra) # 80003bb4 <iunlockput>
    end_op(ROOTDEV);
    80005d9a:	4501                	li	a0,0
    80005d9c:	ffffe097          	auipc	ra,0xffffe
    80005da0:	670080e7          	jalr	1648(ra) # 8000440c <end_op>
    return -1;
    80005da4:	557d                	li	a0,-1
    80005da6:	bfc1                	j	80005d76 <sys_chdir+0x7e>

0000000080005da8 <sys_exec>:

uint64
sys_exec(void)
{
    80005da8:	7145                	addi	sp,sp,-464
    80005daa:	e786                	sd	ra,456(sp)
    80005dac:	e3a2                	sd	s0,448(sp)
    80005dae:	ff26                	sd	s1,440(sp)
    80005db0:	fb4a                	sd	s2,432(sp)
    80005db2:	f74e                	sd	s3,424(sp)
    80005db4:	f352                	sd	s4,416(sp)
    80005db6:	ef56                	sd	s5,408(sp)
    80005db8:	0b80                	addi	s0,sp,464
  char path[MAXPATH], *argv[MAXARG];
  int i;
  uint64 uargv, uarg;

  if(argstr(0, path, MAXPATH) < 0 || argaddr(1, &uargv) < 0){
    80005dba:	08000613          	li	a2,128
    80005dbe:	f4040593          	addi	a1,s0,-192
    80005dc2:	4501                	li	a0,0
    80005dc4:	ffffd097          	auipc	ra,0xffffd
    80005dc8:	f14080e7          	jalr	-236(ra) # 80002cd8 <argstr>
    80005dcc:	10054763          	bltz	a0,80005eda <sys_exec+0x132>
    80005dd0:	e3840593          	addi	a1,s0,-456
    80005dd4:	4505                	li	a0,1
    80005dd6:	ffffd097          	auipc	ra,0xffffd
    80005dda:	ee0080e7          	jalr	-288(ra) # 80002cb6 <argaddr>
    80005dde:	10054863          	bltz	a0,80005eee <sys_exec+0x146>
    return -1;
  }
  memset(argv, 0, sizeof(argv));
    80005de2:	e4040913          	addi	s2,s0,-448
    80005de6:	10000613          	li	a2,256
    80005dea:	4581                	li	a1,0
    80005dec:	854a                	mv	a0,s2
    80005dee:	ffffb097          	auipc	ra,0xffffb
    80005df2:	0ee080e7          	jalr	238(ra) # 80000edc <memset>
  for(i=0;; i++){
    if(i >= NELEM(argv)){
    80005df6:	89ca                	mv	s3,s2
  memset(argv, 0, sizeof(argv));
    80005df8:	4481                	li	s1,0
    if(i >= NELEM(argv)){
    80005dfa:	02000a93          	li	s5,32
    80005dfe:	00048a1b          	sext.w	s4,s1
      goto bad;
    }
    if(fetchaddr(uargv+sizeof(uint64)*i, (uint64*)&uarg) < 0){
    80005e02:	00349513          	slli	a0,s1,0x3
    80005e06:	e3040593          	addi	a1,s0,-464
    80005e0a:	e3843783          	ld	a5,-456(s0)
    80005e0e:	953e                	add	a0,a0,a5
    80005e10:	ffffd097          	auipc	ra,0xffffd
    80005e14:	de8080e7          	jalr	-536(ra) # 80002bf8 <fetchaddr>
    80005e18:	02054a63          	bltz	a0,80005e4c <sys_exec+0xa4>
      goto bad;
    }
    if(uarg == 0){
    80005e1c:	e3043783          	ld	a5,-464(s0)
    80005e20:	cfa1                	beqz	a5,80005e78 <sys_exec+0xd0>
      argv[i] = 0;
      break;
    }
    argv[i] = kalloc();
    80005e22:	ffffb097          	auipc	ra,0xffffb
    80005e26:	bd2080e7          	jalr	-1070(ra) # 800009f4 <kalloc>
    80005e2a:	85aa                	mv	a1,a0
    80005e2c:	00a93023          	sd	a0,0(s2)
    if(argv[i] == 0)
    80005e30:	c949                	beqz	a0,80005ec2 <sys_exec+0x11a>
      panic("sys_exec kalloc");
    if(fetchstr(uarg, argv[i], PGSIZE) < 0){
    80005e32:	6605                	lui	a2,0x1
    80005e34:	e3043503          	ld	a0,-464(s0)
    80005e38:	ffffd097          	auipc	ra,0xffffd
    80005e3c:	e14080e7          	jalr	-492(ra) # 80002c4c <fetchstr>
    80005e40:	00054663          	bltz	a0,80005e4c <sys_exec+0xa4>
    if(i >= NELEM(argv)){
    80005e44:	0485                	addi	s1,s1,1
    80005e46:	0921                	addi	s2,s2,8
    80005e48:	fb549be3          	bne	s1,s5,80005dfe <sys_exec+0x56>
    kfree(argv[i]);

  return ret;

 bad:
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005e4c:	e4043503          	ld	a0,-448(s0)
    80005e50:	c149                	beqz	a0,80005ed2 <sys_exec+0x12a>
    kfree(argv[i]);
    80005e52:	ffffb097          	auipc	ra,0xffffb
    80005e56:	a52080e7          	jalr	-1454(ra) # 800008a4 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005e5a:	e4840493          	addi	s1,s0,-440
    80005e5e:	10098993          	addi	s3,s3,256
    80005e62:	6088                	ld	a0,0(s1)
    80005e64:	c92d                	beqz	a0,80005ed6 <sys_exec+0x12e>
    kfree(argv[i]);
    80005e66:	ffffb097          	auipc	ra,0xffffb
    80005e6a:	a3e080e7          	jalr	-1474(ra) # 800008a4 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005e6e:	04a1                	addi	s1,s1,8
    80005e70:	ff3499e3          	bne	s1,s3,80005e62 <sys_exec+0xba>
  return -1;
    80005e74:	557d                	li	a0,-1
    80005e76:	a09d                	j	80005edc <sys_exec+0x134>
      argv[i] = 0;
    80005e78:	0a0e                	slli	s4,s4,0x3
    80005e7a:	fc040793          	addi	a5,s0,-64
    80005e7e:	9a3e                	add	s4,s4,a5
    80005e80:	e80a3023          	sd	zero,-384(s4)
  int ret = exec(path, argv);
    80005e84:	e4040593          	addi	a1,s0,-448
    80005e88:	f4040513          	addi	a0,s0,-192
    80005e8c:	fffff097          	auipc	ra,0xfffff
    80005e90:	166080e7          	jalr	358(ra) # 80004ff2 <exec>
    80005e94:	892a                	mv	s2,a0
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005e96:	e4043503          	ld	a0,-448(s0)
    80005e9a:	c115                	beqz	a0,80005ebe <sys_exec+0x116>
    kfree(argv[i]);
    80005e9c:	ffffb097          	auipc	ra,0xffffb
    80005ea0:	a08080e7          	jalr	-1528(ra) # 800008a4 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005ea4:	e4840493          	addi	s1,s0,-440
    80005ea8:	10098993          	addi	s3,s3,256
    80005eac:	6088                	ld	a0,0(s1)
    80005eae:	c901                	beqz	a0,80005ebe <sys_exec+0x116>
    kfree(argv[i]);
    80005eb0:	ffffb097          	auipc	ra,0xffffb
    80005eb4:	9f4080e7          	jalr	-1548(ra) # 800008a4 <kfree>
  for(i = 0; i < NELEM(argv) && argv[i] != 0; i++)
    80005eb8:	04a1                	addi	s1,s1,8
    80005eba:	ff3499e3          	bne	s1,s3,80005eac <sys_exec+0x104>
  return ret;
    80005ebe:	854a                	mv	a0,s2
    80005ec0:	a831                	j	80005edc <sys_exec+0x134>
      panic("sys_exec kalloc");
    80005ec2:	00003517          	auipc	a0,0x3
    80005ec6:	9e650513          	addi	a0,a0,-1562 # 800088a8 <userret+0x818>
    80005eca:	ffffa097          	auipc	ra,0xffffa
    80005ece:	6b4080e7          	jalr	1716(ra) # 8000057e <panic>
  return -1;
    80005ed2:	557d                	li	a0,-1
    80005ed4:	a021                	j	80005edc <sys_exec+0x134>
    80005ed6:	557d                	li	a0,-1
    80005ed8:	a011                	j	80005edc <sys_exec+0x134>
    return -1;
    80005eda:	557d                	li	a0,-1
}
    80005edc:	60be                	ld	ra,456(sp)
    80005ede:	641e                	ld	s0,448(sp)
    80005ee0:	74fa                	ld	s1,440(sp)
    80005ee2:	795a                	ld	s2,432(sp)
    80005ee4:	79ba                	ld	s3,424(sp)
    80005ee6:	7a1a                	ld	s4,416(sp)
    80005ee8:	6afa                	ld	s5,408(sp)
    80005eea:	6179                	addi	sp,sp,464
    80005eec:	8082                	ret
    return -1;
    80005eee:	557d                	li	a0,-1
    80005ef0:	b7f5                	j	80005edc <sys_exec+0x134>

0000000080005ef2 <sys_pipe>:

uint64
sys_pipe(void)
{
    80005ef2:	7139                	addi	sp,sp,-64
    80005ef4:	fc06                	sd	ra,56(sp)
    80005ef6:	f822                	sd	s0,48(sp)
    80005ef8:	f426                	sd	s1,40(sp)
    80005efa:	0080                	addi	s0,sp,64
  uint64 fdarray; // user pointer to array of two integers
  struct file *rf, *wf;
  int fd0, fd1;
  struct proc *p = myproc();
    80005efc:	ffffc097          	auipc	ra,0xffffc
    80005f00:	d0a080e7          	jalr	-758(ra) # 80001c06 <myproc>
    80005f04:	84aa                	mv	s1,a0

  if(argaddr(0, &fdarray) < 0)
    80005f06:	fd840593          	addi	a1,s0,-40
    80005f0a:	4501                	li	a0,0
    80005f0c:	ffffd097          	auipc	ra,0xffffd
    80005f10:	daa080e7          	jalr	-598(ra) # 80002cb6 <argaddr>
    return -1;
    80005f14:	57fd                	li	a5,-1
  if(argaddr(0, &fdarray) < 0)
    80005f16:	0c054f63          	bltz	a0,80005ff4 <sys_pipe+0x102>
  if(pipealloc(&rf, &wf) < 0)
    80005f1a:	fc840593          	addi	a1,s0,-56
    80005f1e:	fd040513          	addi	a0,s0,-48
    80005f22:	fffff097          	auipc	ra,0xfffff
    80005f26:	d70080e7          	jalr	-656(ra) # 80004c92 <pipealloc>
    return -1;
    80005f2a:	57fd                	li	a5,-1
  if(pipealloc(&rf, &wf) < 0)
    80005f2c:	0c054463          	bltz	a0,80005ff4 <sys_pipe+0x102>
  fd0 = -1;
    80005f30:	fcf42223          	sw	a5,-60(s0)
  if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){
    80005f34:	fd043503          	ld	a0,-48(s0)
    80005f38:	fffff097          	auipc	ra,0xfffff
    80005f3c:	4ae080e7          	jalr	1198(ra) # 800053e6 <fdalloc>
    80005f40:	fca42223          	sw	a0,-60(s0)
    80005f44:	08054b63          	bltz	a0,80005fda <sys_pipe+0xe8>
    80005f48:	fc843503          	ld	a0,-56(s0)
    80005f4c:	fffff097          	auipc	ra,0xfffff
    80005f50:	49a080e7          	jalr	1178(ra) # 800053e6 <fdalloc>
    80005f54:	fca42023          	sw	a0,-64(s0)
    80005f58:	06054863          	bltz	a0,80005fc8 <sys_pipe+0xd6>
      p->ofile[fd0] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  }
  if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
    80005f5c:	4691                	li	a3,4
    80005f5e:	fc440613          	addi	a2,s0,-60
    80005f62:	fd843583          	ld	a1,-40(s0)
    80005f66:	6ca8                	ld	a0,88(s1)
    80005f68:	ffffc097          	auipc	ra,0xffffc
    80005f6c:	97a080e7          	jalr	-1670(ra) # 800018e2 <copyout>
    80005f70:	02054063          	bltz	a0,80005f90 <sys_pipe+0x9e>
     copyout(p->pagetable, fdarray+sizeof(fd0), (char *)&fd1, sizeof(fd1)) < 0){
    80005f74:	4691                	li	a3,4
    80005f76:	fc040613          	addi	a2,s0,-64
    80005f7a:	fd843583          	ld	a1,-40(s0)
    80005f7e:	0591                	addi	a1,a1,4
    80005f80:	6ca8                	ld	a0,88(s1)
    80005f82:	ffffc097          	auipc	ra,0xffffc
    80005f86:	960080e7          	jalr	-1696(ra) # 800018e2 <copyout>
    p->ofile[fd1] = 0;
    fileclose(rf);
    fileclose(wf);
    return -1;
  }
  return 0;
    80005f8a:	4781                	li	a5,0
  if(copyout(p->pagetable, fdarray, (char*)&fd0, sizeof(fd0)) < 0 ||
    80005f8c:	06055463          	bgez	a0,80005ff4 <sys_pipe+0x102>
    p->ofile[fd0] = 0;
    80005f90:	fc442783          	lw	a5,-60(s0)
    80005f94:	07e9                	addi	a5,a5,26
    80005f96:	078e                	slli	a5,a5,0x3
    80005f98:	97a6                	add	a5,a5,s1
    80005f9a:	0007b423          	sd	zero,8(a5)
    p->ofile[fd1] = 0;
    80005f9e:	fc042783          	lw	a5,-64(s0)
    80005fa2:	07e9                	addi	a5,a5,26
    80005fa4:	078e                	slli	a5,a5,0x3
    80005fa6:	94be                	add	s1,s1,a5
    80005fa8:	0004b423          	sd	zero,8(s1)
    fileclose(rf);
    80005fac:	fd043503          	ld	a0,-48(s0)
    80005fb0:	fffff097          	auipc	ra,0xfffff
    80005fb4:	97e080e7          	jalr	-1666(ra) # 8000492e <fileclose>
    fileclose(wf);
    80005fb8:	fc843503          	ld	a0,-56(s0)
    80005fbc:	fffff097          	auipc	ra,0xfffff
    80005fc0:	972080e7          	jalr	-1678(ra) # 8000492e <fileclose>
    return -1;
    80005fc4:	57fd                	li	a5,-1
    80005fc6:	a03d                	j	80005ff4 <sys_pipe+0x102>
    if(fd0 >= 0)
    80005fc8:	fc442783          	lw	a5,-60(s0)
    80005fcc:	0007c763          	bltz	a5,80005fda <sys_pipe+0xe8>
      p->ofile[fd0] = 0;
    80005fd0:	07e9                	addi	a5,a5,26
    80005fd2:	078e                	slli	a5,a5,0x3
    80005fd4:	94be                	add	s1,s1,a5
    80005fd6:	0004b423          	sd	zero,8(s1)
    fileclose(rf);
    80005fda:	fd043503          	ld	a0,-48(s0)
    80005fde:	fffff097          	auipc	ra,0xfffff
    80005fe2:	950080e7          	jalr	-1712(ra) # 8000492e <fileclose>
    fileclose(wf);
    80005fe6:	fc843503          	ld	a0,-56(s0)
    80005fea:	fffff097          	auipc	ra,0xfffff
    80005fee:	944080e7          	jalr	-1724(ra) # 8000492e <fileclose>
    return -1;
    80005ff2:	57fd                	li	a5,-1
}
    80005ff4:	853e                	mv	a0,a5
    80005ff6:	70e2                	ld	ra,56(sp)
    80005ff8:	7442                	ld	s0,48(sp)
    80005ffa:	74a2                	ld	s1,40(sp)
    80005ffc:	6121                	addi	sp,sp,64
    80005ffe:	8082                	ret

0000000080006000 <kernelvec>:
    80006000:	7111                	addi	sp,sp,-256
    80006002:	e006                	sd	ra,0(sp)
    80006004:	e40a                	sd	sp,8(sp)
    80006006:	e80e                	sd	gp,16(sp)
    80006008:	ec12                	sd	tp,24(sp)
    8000600a:	f016                	sd	t0,32(sp)
    8000600c:	f41a                	sd	t1,40(sp)
    8000600e:	f81e                	sd	t2,48(sp)
    80006010:	fc22                	sd	s0,56(sp)
    80006012:	e0a6                	sd	s1,64(sp)
    80006014:	e4aa                	sd	a0,72(sp)
    80006016:	e8ae                	sd	a1,80(sp)
    80006018:	ecb2                	sd	a2,88(sp)
    8000601a:	f0b6                	sd	a3,96(sp)
    8000601c:	f4ba                	sd	a4,104(sp)
    8000601e:	f8be                	sd	a5,112(sp)
    80006020:	fcc2                	sd	a6,120(sp)
    80006022:	e146                	sd	a7,128(sp)
    80006024:	e54a                	sd	s2,136(sp)
    80006026:	e94e                	sd	s3,144(sp)
    80006028:	ed52                	sd	s4,152(sp)
    8000602a:	f156                	sd	s5,160(sp)
    8000602c:	f55a                	sd	s6,168(sp)
    8000602e:	f95e                	sd	s7,176(sp)
    80006030:	fd62                	sd	s8,184(sp)
    80006032:	e1e6                	sd	s9,192(sp)
    80006034:	e5ea                	sd	s10,200(sp)
    80006036:	e9ee                	sd	s11,208(sp)
    80006038:	edf2                	sd	t3,216(sp)
    8000603a:	f1f6                	sd	t4,224(sp)
    8000603c:	f5fa                	sd	t5,232(sp)
    8000603e:	f9fe                	sd	t6,240(sp)
    80006040:	a81fc0ef          	jal	ra,80002ac0 <kerneltrap>
    80006044:	6082                	ld	ra,0(sp)
    80006046:	6122                	ld	sp,8(sp)
    80006048:	61c2                	ld	gp,16(sp)
    8000604a:	7282                	ld	t0,32(sp)
    8000604c:	7322                	ld	t1,40(sp)
    8000604e:	73c2                	ld	t2,48(sp)
    80006050:	7462                	ld	s0,56(sp)
    80006052:	6486                	ld	s1,64(sp)
    80006054:	6526                	ld	a0,72(sp)
    80006056:	65c6                	ld	a1,80(sp)
    80006058:	6666                	ld	a2,88(sp)
    8000605a:	7686                	ld	a3,96(sp)
    8000605c:	7726                	ld	a4,104(sp)
    8000605e:	77c6                	ld	a5,112(sp)
    80006060:	7866                	ld	a6,120(sp)
    80006062:	688a                	ld	a7,128(sp)
    80006064:	692a                	ld	s2,136(sp)
    80006066:	69ca                	ld	s3,144(sp)
    80006068:	6a6a                	ld	s4,152(sp)
    8000606a:	7a8a                	ld	s5,160(sp)
    8000606c:	7b2a                	ld	s6,168(sp)
    8000606e:	7bca                	ld	s7,176(sp)
    80006070:	7c6a                	ld	s8,184(sp)
    80006072:	6c8e                	ld	s9,192(sp)
    80006074:	6d2e                	ld	s10,200(sp)
    80006076:	6dce                	ld	s11,208(sp)
    80006078:	6e6e                	ld	t3,216(sp)
    8000607a:	7e8e                	ld	t4,224(sp)
    8000607c:	7f2e                	ld	t5,232(sp)
    8000607e:	7fce                	ld	t6,240(sp)
    80006080:	6111                	addi	sp,sp,256
    80006082:	10200073          	sret
    80006086:	00000013          	nop
    8000608a:	00000013          	nop
    8000608e:	0001                	nop

0000000080006090 <timervec>:
    80006090:	34051573          	csrrw	a0,mscratch,a0
    80006094:	e10c                	sd	a1,0(a0)
    80006096:	e510                	sd	a2,8(a0)
    80006098:	e914                	sd	a3,16(a0)
    8000609a:	710c                	ld	a1,32(a0)
    8000609c:	7510                	ld	a2,40(a0)
    8000609e:	6194                	ld	a3,0(a1)
    800060a0:	96b2                	add	a3,a3,a2
    800060a2:	e194                	sd	a3,0(a1)
    800060a4:	4589                	li	a1,2
    800060a6:	14459073          	csrw	sip,a1
    800060aa:	6914                	ld	a3,16(a0)
    800060ac:	6510                	ld	a2,8(a0)
    800060ae:	610c                	ld	a1,0(a0)
    800060b0:	34051573          	csrrw	a0,mscratch,a0
    800060b4:	30200073          	mret
	...

00000000800060ba <plicinit>:
// the riscv Platform Level Interrupt Controller (PLIC).
//

void
plicinit(void)
{
    800060ba:	1141                	addi	sp,sp,-16
    800060bc:	e422                	sd	s0,8(sp)
    800060be:	0800                	addi	s0,sp,16
  // set desired IRQ priorities non-zero (otherwise disabled).
  *(uint32*)(PLIC + UART0_IRQ*4) = 1;
    800060c0:	0c0007b7          	lui	a5,0xc000
    800060c4:	4705                	li	a4,1
    800060c6:	d798                	sw	a4,40(a5)
  *(uint32*)(PLIC + VIRTIO0_IRQ*4) = 1;
    800060c8:	c3d8                	sw	a4,4(a5)
}
    800060ca:	6422                	ld	s0,8(sp)
    800060cc:	0141                	addi	sp,sp,16
    800060ce:	8082                	ret

00000000800060d0 <plicinithart>:

void
plicinithart(void)
{
    800060d0:	1141                	addi	sp,sp,-16
    800060d2:	e406                	sd	ra,8(sp)
    800060d4:	e022                	sd	s0,0(sp)
    800060d6:	0800                	addi	s0,sp,16
  int hart = cpuid();
    800060d8:	ffffc097          	auipc	ra,0xffffc
    800060dc:	b02080e7          	jalr	-1278(ra) # 80001bda <cpuid>
  
  // set uart's enable bit for this hart's S-mode. 
  *(uint32*)PLIC_SENABLE(hart)= (1 << UART0_IRQ) | (1 << VIRTIO0_IRQ);
    800060e0:	0085171b          	slliw	a4,a0,0x8
    800060e4:	0c0027b7          	lui	a5,0xc002
    800060e8:	97ba                	add	a5,a5,a4
    800060ea:	40200713          	li	a4,1026
    800060ee:	08e7a023          	sw	a4,128(a5) # c002080 <_entry-0x73ffdf80>

  // set this hart's S-mode priority threshold to 0.
  *(uint32*)PLIC_SPRIORITY(hart) = 0;
    800060f2:	00d5151b          	slliw	a0,a0,0xd
    800060f6:	0c2017b7          	lui	a5,0xc201
    800060fa:	953e                	add	a0,a0,a5
    800060fc:	00052023          	sw	zero,0(a0)
}
    80006100:	60a2                	ld	ra,8(sp)
    80006102:	6402                	ld	s0,0(sp)
    80006104:	0141                	addi	sp,sp,16
    80006106:	8082                	ret

0000000080006108 <plic_claim>:

// ask the PLIC what interrupt we should serve.
int
plic_claim(void)
{
    80006108:	1141                	addi	sp,sp,-16
    8000610a:	e406                	sd	ra,8(sp)
    8000610c:	e022                	sd	s0,0(sp)
    8000610e:	0800                	addi	s0,sp,16
  int hart = cpuid();
    80006110:	ffffc097          	auipc	ra,0xffffc
    80006114:	aca080e7          	jalr	-1334(ra) # 80001bda <cpuid>
  //int irq = *(uint32*)(PLIC + 0x201004);
  int irq = *(uint32*)PLIC_SCLAIM(hart);
    80006118:	00d5151b          	slliw	a0,a0,0xd
    8000611c:	0c2017b7          	lui	a5,0xc201
    80006120:	97aa                	add	a5,a5,a0
  return irq;
}
    80006122:	43c8                	lw	a0,4(a5)
    80006124:	60a2                	ld	ra,8(sp)
    80006126:	6402                	ld	s0,0(sp)
    80006128:	0141                	addi	sp,sp,16
    8000612a:	8082                	ret

000000008000612c <plic_complete>:

// tell the PLIC we've served this IRQ.
void
plic_complete(int irq)
{
    8000612c:	1101                	addi	sp,sp,-32
    8000612e:	ec06                	sd	ra,24(sp)
    80006130:	e822                	sd	s0,16(sp)
    80006132:	e426                	sd	s1,8(sp)
    80006134:	1000                	addi	s0,sp,32
    80006136:	84aa                	mv	s1,a0
  int hart = cpuid();
    80006138:	ffffc097          	auipc	ra,0xffffc
    8000613c:	aa2080e7          	jalr	-1374(ra) # 80001bda <cpuid>
  //*(uint32*)(PLIC + 0x201004) = irq;
  *(uint32*)PLIC_SCLAIM(hart) = irq;
    80006140:	00d5151b          	slliw	a0,a0,0xd
    80006144:	0c2017b7          	lui	a5,0xc201
    80006148:	97aa                	add	a5,a5,a0
    8000614a:	c3c4                	sw	s1,4(a5)
}
    8000614c:	60e2                	ld	ra,24(sp)
    8000614e:	6442                	ld	s0,16(sp)
    80006150:	64a2                	ld	s1,8(sp)
    80006152:	6105                	addi	sp,sp,32
    80006154:	8082                	ret

0000000080006156 <free_desc>:
}

// mark a descriptor as free.
static void
free_desc(int n, int i)
{
    80006156:	1141                	addi	sp,sp,-16
    80006158:	e406                	sd	ra,8(sp)
    8000615a:	e022                	sd	s0,0(sp)
    8000615c:	0800                	addi	s0,sp,16
  if(i >= NUM)
    8000615e:	479d                	li	a5,7
    80006160:	06b7c863          	blt	a5,a1,800061d0 <free_desc+0x7a>
    panic("virtio_disk_intr 1");
  if(disk[n].free[i])
    80006164:	00151713          	slli	a4,a0,0x1
    80006168:	972a                	add	a4,a4,a0
    8000616a:	00c71693          	slli	a3,a4,0xc
    8000616e:	00024717          	auipc	a4,0x24
    80006172:	e9270713          	addi	a4,a4,-366 # 8002a000 <disk>
    80006176:	9736                	add	a4,a4,a3
    80006178:	972e                	add	a4,a4,a1
    8000617a:	6789                	lui	a5,0x2
    8000617c:	973e                	add	a4,a4,a5
    8000617e:	01874783          	lbu	a5,24(a4)
    80006182:	efb9                	bnez	a5,800061e0 <free_desc+0x8a>
    panic("virtio_disk_intr 2");
  disk[n].desc[i].addr = 0;
    80006184:	00024817          	auipc	a6,0x24
    80006188:	e7c80813          	addi	a6,a6,-388 # 8002a000 <disk>
    8000618c:	00151713          	slli	a4,a0,0x1
    80006190:	00a707b3          	add	a5,a4,a0
    80006194:	07b2                	slli	a5,a5,0xc
    80006196:	97c2                	add	a5,a5,a6
    80006198:	6689                	lui	a3,0x2
    8000619a:	00f68633          	add	a2,a3,a5
    8000619e:	6210                	ld	a2,0(a2)
    800061a0:	00459893          	slli	a7,a1,0x4
    800061a4:	9646                	add	a2,a2,a7
    800061a6:	00063023          	sd	zero,0(a2) # 1000 <_entry-0x7ffff000>
  disk[n].free[i] = 1;
    800061aa:	97ae                	add	a5,a5,a1
    800061ac:	97b6                	add	a5,a5,a3
    800061ae:	4605                	li	a2,1
    800061b0:	00c78c23          	sb	a2,24(a5) # 2018 <_entry-0x7fffdfe8>
  wakeup(&disk[n].free[0]);
    800061b4:	972a                	add	a4,a4,a0
    800061b6:	0732                	slli	a4,a4,0xc
    800061b8:	06e1                	addi	a3,a3,24
    800061ba:	9736                	add	a4,a4,a3
    800061bc:	00e80533          	add	a0,a6,a4
    800061c0:	ffffc097          	auipc	ra,0xffffc
    800061c4:	3a8080e7          	jalr	936(ra) # 80002568 <wakeup>
}
    800061c8:	60a2                	ld	ra,8(sp)
    800061ca:	6402                	ld	s0,0(sp)
    800061cc:	0141                	addi	sp,sp,16
    800061ce:	8082                	ret
    panic("virtio_disk_intr 1");
    800061d0:	00002517          	auipc	a0,0x2
    800061d4:	6e850513          	addi	a0,a0,1768 # 800088b8 <userret+0x828>
    800061d8:	ffffa097          	auipc	ra,0xffffa
    800061dc:	3a6080e7          	jalr	934(ra) # 8000057e <panic>
    panic("virtio_disk_intr 2");
    800061e0:	00002517          	auipc	a0,0x2
    800061e4:	6f050513          	addi	a0,a0,1776 # 800088d0 <userret+0x840>
    800061e8:	ffffa097          	auipc	ra,0xffffa
    800061ec:	396080e7          	jalr	918(ra) # 8000057e <panic>

00000000800061f0 <virtio_disk_init>:
  __sync_synchronize();
    800061f0:	0ff0000f          	fence
  if(disk[n].init)
    800061f4:	00151793          	slli	a5,a0,0x1
    800061f8:	97aa                	add	a5,a5,a0
    800061fa:	07b2                	slli	a5,a5,0xc
    800061fc:	00024717          	auipc	a4,0x24
    80006200:	e0470713          	addi	a4,a4,-508 # 8002a000 <disk>
    80006204:	973e                	add	a4,a4,a5
    80006206:	6789                	lui	a5,0x2
    80006208:	97ba                	add	a5,a5,a4
    8000620a:	0a87a783          	lw	a5,168(a5) # 20a8 <_entry-0x7fffdf58>
    8000620e:	c391                	beqz	a5,80006212 <virtio_disk_init+0x22>
    80006210:	8082                	ret
{
    80006212:	7139                	addi	sp,sp,-64
    80006214:	fc06                	sd	ra,56(sp)
    80006216:	f822                	sd	s0,48(sp)
    80006218:	f426                	sd	s1,40(sp)
    8000621a:	f04a                	sd	s2,32(sp)
    8000621c:	ec4e                	sd	s3,24(sp)
    8000621e:	e852                	sd	s4,16(sp)
    80006220:	e456                	sd	s5,8(sp)
    80006222:	0080                	addi	s0,sp,64
    80006224:	892a                	mv	s2,a0
  printf("virtio disk init %d\n", n);
    80006226:	85aa                	mv	a1,a0
    80006228:	00002517          	auipc	a0,0x2
    8000622c:	6c050513          	addi	a0,a0,1728 # 800088e8 <userret+0x858>
    80006230:	ffffa097          	auipc	ra,0xffffa
    80006234:	3a8080e7          	jalr	936(ra) # 800005d8 <printf>
  initlock(&disk[n].vdisk_lock, "virtio_disk");
    80006238:	00191993          	slli	s3,s2,0x1
    8000623c:	99ca                	add	s3,s3,s2
    8000623e:	09b2                	slli	s3,s3,0xc
    80006240:	6789                	lui	a5,0x2
    80006242:	0b078793          	addi	a5,a5,176 # 20b0 <_entry-0x7fffdf50>
    80006246:	97ce                	add	a5,a5,s3
    80006248:	00002597          	auipc	a1,0x2
    8000624c:	6b858593          	addi	a1,a1,1720 # 80008900 <userret+0x870>
    80006250:	00024517          	auipc	a0,0x24
    80006254:	db050513          	addi	a0,a0,-592 # 8002a000 <disk>
    80006258:	953e                	add	a0,a0,a5
    8000625a:	ffffb097          	auipc	ra,0xffffb
    8000625e:	89c080e7          	jalr	-1892(ra) # 80000af6 <initlock>
  if(*R(n, VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
    80006262:	0019049b          	addiw	s1,s2,1
    80006266:	00c4949b          	slliw	s1,s1,0xc
    8000626a:	100007b7          	lui	a5,0x10000
    8000626e:	97a6                	add	a5,a5,s1
    80006270:	4398                	lw	a4,0(a5)
    80006272:	2701                	sext.w	a4,a4
    80006274:	747277b7          	lui	a5,0x74727
    80006278:	97678793          	addi	a5,a5,-1674 # 74726976 <_entry-0xb8d968a>
    8000627c:	12f71763          	bne	a4,a5,800063aa <virtio_disk_init+0x1ba>
     *R(n, VIRTIO_MMIO_VERSION) != 1 ||
    80006280:	100007b7          	lui	a5,0x10000
    80006284:	0791                	addi	a5,a5,4
    80006286:	97a6                	add	a5,a5,s1
    80006288:	439c                	lw	a5,0(a5)
    8000628a:	2781                	sext.w	a5,a5
  if(*R(n, VIRTIO_MMIO_MAGIC_VALUE) != 0x74726976 ||
    8000628c:	4705                	li	a4,1
    8000628e:	10e79e63          	bne	a5,a4,800063aa <virtio_disk_init+0x1ba>
     *R(n, VIRTIO_MMIO_DEVICE_ID) != 2 ||
    80006292:	100007b7          	lui	a5,0x10000
    80006296:	07a1                	addi	a5,a5,8
    80006298:	97a6                	add	a5,a5,s1
    8000629a:	439c                	lw	a5,0(a5)
    8000629c:	2781                	sext.w	a5,a5
     *R(n, VIRTIO_MMIO_VERSION) != 1 ||
    8000629e:	4709                	li	a4,2
    800062a0:	10e79563          	bne	a5,a4,800063aa <virtio_disk_init+0x1ba>
     *R(n, VIRTIO_MMIO_VENDOR_ID) != 0x554d4551){
    800062a4:	100007b7          	lui	a5,0x10000
    800062a8:	07b1                	addi	a5,a5,12
    800062aa:	97a6                	add	a5,a5,s1
    800062ac:	4398                	lw	a4,0(a5)
    800062ae:	2701                	sext.w	a4,a4
     *R(n, VIRTIO_MMIO_DEVICE_ID) != 2 ||
    800062b0:	554d47b7          	lui	a5,0x554d4
    800062b4:	55178793          	addi	a5,a5,1361 # 554d4551 <_entry-0x2ab2baaf>
    800062b8:	0ef71963          	bne	a4,a5,800063aa <virtio_disk_init+0x1ba>
  *R(n, VIRTIO_MMIO_STATUS) = status;
    800062bc:	100007b7          	lui	a5,0x10000
    800062c0:	07078693          	addi	a3,a5,112 # 10000070 <_entry-0x6fffff90>
    800062c4:	96a6                	add	a3,a3,s1
    800062c6:	4705                	li	a4,1
    800062c8:	c298                	sw	a4,0(a3)
  *R(n, VIRTIO_MMIO_STATUS) = status;
    800062ca:	470d                	li	a4,3
    800062cc:	c298                	sw	a4,0(a3)
  uint64 features = *R(n, VIRTIO_MMIO_DEVICE_FEATURES);
    800062ce:	01078713          	addi	a4,a5,16
    800062d2:	9726                	add	a4,a4,s1
    800062d4:	430c                	lw	a1,0(a4)
  *R(n, VIRTIO_MMIO_DRIVER_FEATURES) = features;
    800062d6:	02078613          	addi	a2,a5,32
    800062da:	9626                	add	a2,a2,s1
  features &= ~(1 << VIRTIO_RING_F_INDIRECT_DESC);
    800062dc:	c7ffe737          	lui	a4,0xc7ffe
    800062e0:	75f70713          	addi	a4,a4,1887 # ffffffffc7ffe75f <end+0xffffffff47fce703>
    800062e4:	8f6d                	and	a4,a4,a1
  *R(n, VIRTIO_MMIO_DRIVER_FEATURES) = features;
    800062e6:	2701                	sext.w	a4,a4
    800062e8:	c218                	sw	a4,0(a2)
  *R(n, VIRTIO_MMIO_STATUS) = status;
    800062ea:	472d                	li	a4,11
    800062ec:	c298                	sw	a4,0(a3)
  *R(n, VIRTIO_MMIO_STATUS) = status;
    800062ee:	473d                	li	a4,15
    800062f0:	c298                	sw	a4,0(a3)
  *R(n, VIRTIO_MMIO_GUEST_PAGE_SIZE) = PGSIZE;
    800062f2:	02878713          	addi	a4,a5,40
    800062f6:	9726                	add	a4,a4,s1
    800062f8:	6685                	lui	a3,0x1
    800062fa:	c314                	sw	a3,0(a4)
  *R(n, VIRTIO_MMIO_QUEUE_SEL) = 0;
    800062fc:	03078713          	addi	a4,a5,48
    80006300:	9726                	add	a4,a4,s1
    80006302:	00072023          	sw	zero,0(a4)
  uint32 max = *R(n, VIRTIO_MMIO_QUEUE_NUM_MAX);
    80006306:	03478793          	addi	a5,a5,52
    8000630a:	97a6                	add	a5,a5,s1
    8000630c:	439c                	lw	a5,0(a5)
    8000630e:	2781                	sext.w	a5,a5
  if(max == 0)
    80006310:	c7cd                	beqz	a5,800063ba <virtio_disk_init+0x1ca>
  if(max < NUM)
    80006312:	471d                	li	a4,7
    80006314:	0af77b63          	bleu	a5,a4,800063ca <virtio_disk_init+0x1da>
  *R(n, VIRTIO_MMIO_QUEUE_NUM) = NUM;
    80006318:	10000ab7          	lui	s5,0x10000
    8000631c:	038a8793          	addi	a5,s5,56 # 10000038 <_entry-0x6fffffc8>
    80006320:	97a6                	add	a5,a5,s1
    80006322:	4721                	li	a4,8
    80006324:	c398                	sw	a4,0(a5)
  memset(disk[n].pages, 0, sizeof(disk[n].pages));
    80006326:	00024a17          	auipc	s4,0x24
    8000632a:	cdaa0a13          	addi	s4,s4,-806 # 8002a000 <disk>
    8000632e:	99d2                	add	s3,s3,s4
    80006330:	6609                	lui	a2,0x2
    80006332:	4581                	li	a1,0
    80006334:	854e                	mv	a0,s3
    80006336:	ffffb097          	auipc	ra,0xffffb
    8000633a:	ba6080e7          	jalr	-1114(ra) # 80000edc <memset>
  *R(n, VIRTIO_MMIO_QUEUE_PFN) = ((uint64)disk[n].pages) >> PGSHIFT;
    8000633e:	040a8a93          	addi	s5,s5,64
    80006342:	94d6                	add	s1,s1,s5
    80006344:	00c9d793          	srli	a5,s3,0xc
    80006348:	2781                	sext.w	a5,a5
    8000634a:	c09c                	sw	a5,0(s1)
  disk[n].desc = (struct VRingDesc *) disk[n].pages;
    8000634c:	00191513          	slli	a0,s2,0x1
    80006350:	012507b3          	add	a5,a0,s2
    80006354:	07b2                	slli	a5,a5,0xc
    80006356:	97d2                	add	a5,a5,s4
    80006358:	6689                	lui	a3,0x2
    8000635a:	97b6                	add	a5,a5,a3
    8000635c:	0137b023          	sd	s3,0(a5)
  disk[n].avail = (uint16*)(((char*)disk[n].desc) + NUM*sizeof(struct VRingDesc));
    80006360:	08098713          	addi	a4,s3,128
    80006364:	e798                	sd	a4,8(a5)
  disk[n].used = (struct UsedArea *) (disk[n].pages + PGSIZE);
    80006366:	6705                	lui	a4,0x1
    80006368:	99ba                	add	s3,s3,a4
    8000636a:	0137b823          	sd	s3,16(a5)
    disk[n].free[i] = 1;
    8000636e:	4705                	li	a4,1
    80006370:	00e78c23          	sb	a4,24(a5)
    80006374:	00e78ca3          	sb	a4,25(a5)
    80006378:	00e78d23          	sb	a4,26(a5)
    8000637c:	00e78da3          	sb	a4,27(a5)
    80006380:	00e78e23          	sb	a4,28(a5)
    80006384:	00e78ea3          	sb	a4,29(a5)
    80006388:	00e78f23          	sb	a4,30(a5)
    8000638c:	00e78fa3          	sb	a4,31(a5)
  disk[n].init = 1;
    80006390:	853e                	mv	a0,a5
    80006392:	4785                	li	a5,1
    80006394:	0af52423          	sw	a5,168(a0)
}
    80006398:	70e2                	ld	ra,56(sp)
    8000639a:	7442                	ld	s0,48(sp)
    8000639c:	74a2                	ld	s1,40(sp)
    8000639e:	7902                	ld	s2,32(sp)
    800063a0:	69e2                	ld	s3,24(sp)
    800063a2:	6a42                	ld	s4,16(sp)
    800063a4:	6aa2                	ld	s5,8(sp)
    800063a6:	6121                	addi	sp,sp,64
    800063a8:	8082                	ret
    panic("could not find virtio disk");
    800063aa:	00002517          	auipc	a0,0x2
    800063ae:	56650513          	addi	a0,a0,1382 # 80008910 <userret+0x880>
    800063b2:	ffffa097          	auipc	ra,0xffffa
    800063b6:	1cc080e7          	jalr	460(ra) # 8000057e <panic>
    panic("virtio disk has no queue 0");
    800063ba:	00002517          	auipc	a0,0x2
    800063be:	57650513          	addi	a0,a0,1398 # 80008930 <userret+0x8a0>
    800063c2:	ffffa097          	auipc	ra,0xffffa
    800063c6:	1bc080e7          	jalr	444(ra) # 8000057e <panic>
    panic("virtio disk max queue too short");
    800063ca:	00002517          	auipc	a0,0x2
    800063ce:	58650513          	addi	a0,a0,1414 # 80008950 <userret+0x8c0>
    800063d2:	ffffa097          	auipc	ra,0xffffa
    800063d6:	1ac080e7          	jalr	428(ra) # 8000057e <panic>

00000000800063da <virtio_disk_rw>:
  return 0;
}

void
virtio_disk_rw(int n, struct buf *b, int write)
{
    800063da:	7175                	addi	sp,sp,-144
    800063dc:	e506                	sd	ra,136(sp)
    800063de:	e122                	sd	s0,128(sp)
    800063e0:	fca6                	sd	s1,120(sp)
    800063e2:	f8ca                	sd	s2,112(sp)
    800063e4:	f4ce                	sd	s3,104(sp)
    800063e6:	f0d2                	sd	s4,96(sp)
    800063e8:	ecd6                	sd	s5,88(sp)
    800063ea:	e8da                	sd	s6,80(sp)
    800063ec:	e4de                	sd	s7,72(sp)
    800063ee:	e0e2                	sd	s8,64(sp)
    800063f0:	fc66                	sd	s9,56(sp)
    800063f2:	f86a                	sd	s10,48(sp)
    800063f4:	f46e                	sd	s11,40(sp)
    800063f6:	0900                	addi	s0,sp,144
    800063f8:	892a                	mv	s2,a0
    800063fa:	8a2e                	mv	s4,a1
    800063fc:	8db2                	mv	s11,a2
  uint64 sector = b->blockno * (BSIZE / 512);
    800063fe:	00c5ad03          	lw	s10,12(a1)
    80006402:	001d1d1b          	slliw	s10,s10,0x1
    80006406:	1d02                	slli	s10,s10,0x20
    80006408:	020d5d13          	srli	s10,s10,0x20

  acquire(&disk[n].vdisk_lock);
    8000640c:	00151493          	slli	s1,a0,0x1
    80006410:	94aa                	add	s1,s1,a0
    80006412:	04b2                	slli	s1,s1,0xc
    80006414:	6a89                	lui	s5,0x2
    80006416:	0b0a8993          	addi	s3,s5,176 # 20b0 <_entry-0x7fffdf50>
    8000641a:	99a6                	add	s3,s3,s1
    8000641c:	00024c17          	auipc	s8,0x24
    80006420:	be4c0c13          	addi	s8,s8,-1052 # 8002a000 <disk>
    80006424:	99e2                	add	s3,s3,s8
    80006426:	854e                	mv	a0,s3
    80006428:	ffffb097          	auipc	ra,0xffffb
    8000642c:	81e080e7          	jalr	-2018(ra) # 80000c46 <acquire>
  int idx[3];
  while(1){
    if(alloc3_desc(n, idx) == 0) {
      break;
    }
    sleep(&disk[n].free[0], &disk[n].vdisk_lock);
    80006430:	018a8b93          	addi	s7,s5,24
    80006434:	9ba6                	add	s7,s7,s1
    80006436:	9be2                	add	s7,s7,s8
    80006438:	0ae5                	addi	s5,s5,25
    8000643a:	94d6                	add	s1,s1,s5
    8000643c:	01848ab3          	add	s5,s1,s8
    if(disk[n].free[i]){
    80006440:	00191b13          	slli	s6,s2,0x1
    80006444:	9b4a                	add	s6,s6,s2
    80006446:	00cb1793          	slli	a5,s6,0xc
    8000644a:	00fc0b33          	add	s6,s8,a5
    8000644e:	6c89                	lui	s9,0x2
    80006450:	016c8c33          	add	s8,s9,s6
    80006454:	a049                	j	800064d6 <virtio_disk_rw+0xfc>
      disk[n].free[i] = 0;
    80006456:	00fb06b3          	add	a3,s6,a5
    8000645a:	96e6                	add	a3,a3,s9
    8000645c:	00068c23          	sb	zero,24(a3) # 2018 <_entry-0x7fffdfe8>
    idx[i] = alloc_desc(n);
    80006460:	c21c                	sw	a5,0(a2)
    if(idx[i] < 0){
    80006462:	0207c763          	bltz	a5,80006490 <virtio_disk_rw+0xb6>
  for(int i = 0; i < 3; i++){
    80006466:	2485                	addiw	s1,s1,1
    80006468:	0711                	addi	a4,a4,4
    8000646a:	28b48063          	beq	s1,a1,800066ea <virtio_disk_rw+0x310>
    idx[i] = alloc_desc(n);
    8000646e:	863a                	mv	a2,a4
    if(disk[n].free[i]){
    80006470:	018c4783          	lbu	a5,24(s8)
    80006474:	28079063          	bnez	a5,800066f4 <virtio_disk_rw+0x31a>
    80006478:	86d6                	mv	a3,s5
  for(int i = 0; i < NUM; i++){
    8000647a:	87c2                	mv	a5,a6
    if(disk[n].free[i]){
    8000647c:	0006c883          	lbu	a7,0(a3)
    80006480:	fc089be3          	bnez	a7,80006456 <virtio_disk_rw+0x7c>
  for(int i = 0; i < NUM; i++){
    80006484:	2785                	addiw	a5,a5,1
    80006486:	0685                	addi	a3,a3,1
    80006488:	fea79ae3          	bne	a5,a0,8000647c <virtio_disk_rw+0xa2>
    idx[i] = alloc_desc(n);
    8000648c:	57fd                	li	a5,-1
    8000648e:	c21c                	sw	a5,0(a2)
      for(int j = 0; j < i; j++)
    80006490:	02905d63          	blez	s1,800064ca <virtio_disk_rw+0xf0>
        free_desc(n, idx[j]);
    80006494:	f8042583          	lw	a1,-128(s0)
    80006498:	854a                	mv	a0,s2
    8000649a:	00000097          	auipc	ra,0x0
    8000649e:	cbc080e7          	jalr	-836(ra) # 80006156 <free_desc>
      for(int j = 0; j < i; j++)
    800064a2:	4785                	li	a5,1
    800064a4:	0297d363          	ble	s1,a5,800064ca <virtio_disk_rw+0xf0>
        free_desc(n, idx[j]);
    800064a8:	f8442583          	lw	a1,-124(s0)
    800064ac:	854a                	mv	a0,s2
    800064ae:	00000097          	auipc	ra,0x0
    800064b2:	ca8080e7          	jalr	-856(ra) # 80006156 <free_desc>
      for(int j = 0; j < i; j++)
    800064b6:	4789                	li	a5,2
    800064b8:	0097d963          	ble	s1,a5,800064ca <virtio_disk_rw+0xf0>
        free_desc(n, idx[j]);
    800064bc:	f8842583          	lw	a1,-120(s0)
    800064c0:	854a                	mv	a0,s2
    800064c2:	00000097          	auipc	ra,0x0
    800064c6:	c94080e7          	jalr	-876(ra) # 80006156 <free_desc>
    sleep(&disk[n].free[0], &disk[n].vdisk_lock);
    800064ca:	85ce                	mv	a1,s3
    800064cc:	855e                	mv	a0,s7
    800064ce:	ffffc097          	auipc	ra,0xffffc
    800064d2:	f14080e7          	jalr	-236(ra) # 800023e2 <sleep>
  for(int i = 0; i < 3; i++){
    800064d6:	f8040713          	addi	a4,s0,-128
    800064da:	4481                	li	s1,0
  for(int i = 0; i < NUM; i++){
    800064dc:	4805                	li	a6,1
    800064de:	4521                	li	a0,8
  for(int i = 0; i < 3; i++){
    800064e0:	458d                	li	a1,3
    800064e2:	b771                	j	8000646e <virtio_disk_rw+0x94>
    uint32 reserved;
    uint64 sector;
  } buf0;

  if(write)
    buf0.type = VIRTIO_BLK_T_OUT; // write the disk
    800064e4:	4785                	li	a5,1
    800064e6:	f6f42823          	sw	a5,-144(s0)
  else
    buf0.type = VIRTIO_BLK_T_IN; // read the disk
  buf0.reserved = 0;
    800064ea:	f6042a23          	sw	zero,-140(s0)
  buf0.sector = sector;
    800064ee:	f7a43c23          	sd	s10,-136(s0)

  // buf0 is on a kernel stack, which is not direct mapped,
  // thus the call to kvmpa().
  disk[n].desc[idx[0]].addr = (uint64) kvmpa((uint64) &buf0);
    800064f2:	f8042483          	lw	s1,-128(s0)
    800064f6:	00449b13          	slli	s6,s1,0x4
    800064fa:	00191793          	slli	a5,s2,0x1
    800064fe:	97ca                	add	a5,a5,s2
    80006500:	07b2                	slli	a5,a5,0xc
    80006502:	00024a97          	auipc	s5,0x24
    80006506:	afea8a93          	addi	s5,s5,-1282 # 8002a000 <disk>
    8000650a:	97d6                	add	a5,a5,s5
    8000650c:	6a89                	lui	s5,0x2
    8000650e:	9abe                	add	s5,s5,a5
    80006510:	000abb83          	ld	s7,0(s5) # 2000 <_entry-0x7fffe000>
    80006514:	9bda                	add	s7,s7,s6
    80006516:	f7040513          	addi	a0,s0,-144
    8000651a:	ffffb097          	auipc	ra,0xffffb
    8000651e:	e26080e7          	jalr	-474(ra) # 80001340 <kvmpa>
    80006522:	00abb023          	sd	a0,0(s7)
  disk[n].desc[idx[0]].len = sizeof(buf0);
    80006526:	000ab783          	ld	a5,0(s5)
    8000652a:	97da                	add	a5,a5,s6
    8000652c:	4741                	li	a4,16
    8000652e:	c798                	sw	a4,8(a5)
  disk[n].desc[idx[0]].flags = VRING_DESC_F_NEXT;
    80006530:	000ab783          	ld	a5,0(s5)
    80006534:	97da                	add	a5,a5,s6
    80006536:	4705                	li	a4,1
    80006538:	00e79623          	sh	a4,12(a5)
  disk[n].desc[idx[0]].next = idx[1];
    8000653c:	f8442603          	lw	a2,-124(s0)
    80006540:	000ab783          	ld	a5,0(s5)
    80006544:	9b3e                	add	s6,s6,a5
    80006546:	00cb1723          	sh	a2,14(s6)

  disk[n].desc[idx[1]].addr = (uint64) b->data;
    8000654a:	0612                	slli	a2,a2,0x4
    8000654c:	000ab783          	ld	a5,0(s5)
    80006550:	97b2                	add	a5,a5,a2
    80006552:	064a0713          	addi	a4,s4,100
    80006556:	e398                	sd	a4,0(a5)
  disk[n].desc[idx[1]].len = BSIZE;
    80006558:	000ab783          	ld	a5,0(s5)
    8000655c:	97b2                	add	a5,a5,a2
    8000655e:	40000713          	li	a4,1024
    80006562:	c798                	sw	a4,8(a5)
  if(write)
    80006564:	120d8e63          	beqz	s11,800066a0 <virtio_disk_rw+0x2c6>
    disk[n].desc[idx[1]].flags = 0; // device reads b->data
    80006568:	000ab783          	ld	a5,0(s5)
    8000656c:	97b2                	add	a5,a5,a2
    8000656e:	00079623          	sh	zero,12(a5)
  else
    disk[n].desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
  disk[n].desc[idx[1]].flags |= VRING_DESC_F_NEXT;
    80006572:	00024517          	auipc	a0,0x24
    80006576:	a8e50513          	addi	a0,a0,-1394 # 8002a000 <disk>
    8000657a:	00191793          	slli	a5,s2,0x1
    8000657e:	012786b3          	add	a3,a5,s2
    80006582:	06b2                	slli	a3,a3,0xc
    80006584:	96aa                	add	a3,a3,a0
    80006586:	6709                	lui	a4,0x2
    80006588:	96ba                	add	a3,a3,a4
    8000658a:	628c                	ld	a1,0(a3)
    8000658c:	95b2                	add	a1,a1,a2
    8000658e:	00c5d703          	lhu	a4,12(a1)
    80006592:	00176713          	ori	a4,a4,1
    80006596:	00e59623          	sh	a4,12(a1)
  disk[n].desc[idx[1]].next = idx[2];
    8000659a:	f8842583          	lw	a1,-120(s0)
    8000659e:	6298                	ld	a4,0(a3)
    800065a0:	963a                	add	a2,a2,a4
    800065a2:	00b61723          	sh	a1,14(a2) # 200e <_entry-0x7fffdff2>

  disk[n].info[idx[0]].status = 0;
    800065a6:	97ca                	add	a5,a5,s2
    800065a8:	07a2                	slli	a5,a5,0x8
    800065aa:	97a6                	add	a5,a5,s1
    800065ac:	20078793          	addi	a5,a5,512
    800065b0:	0792                	slli	a5,a5,0x4
    800065b2:	97aa                	add	a5,a5,a0
    800065b4:	02078823          	sb	zero,48(a5)
  disk[n].desc[idx[2]].addr = (uint64) &disk[n].info[idx[0]].status;
    800065b8:	00459613          	slli	a2,a1,0x4
    800065bc:	628c                	ld	a1,0(a3)
    800065be:	95b2                	add	a1,a1,a2
    800065c0:	00191713          	slli	a4,s2,0x1
    800065c4:	974a                	add	a4,a4,s2
    800065c6:	0722                	slli	a4,a4,0x8
    800065c8:	20348813          	addi	a6,s1,515
    800065cc:	9742                	add	a4,a4,a6
    800065ce:	0712                	slli	a4,a4,0x4
    800065d0:	972a                	add	a4,a4,a0
    800065d2:	e198                	sd	a4,0(a1)
  disk[n].desc[idx[2]].len = 1;
    800065d4:	6298                	ld	a4,0(a3)
    800065d6:	9732                	add	a4,a4,a2
    800065d8:	4585                	li	a1,1
    800065da:	c70c                	sw	a1,8(a4)
  disk[n].desc[idx[2]].flags = VRING_DESC_F_WRITE; // device writes the status
    800065dc:	6298                	ld	a4,0(a3)
    800065de:	9732                	add	a4,a4,a2
    800065e0:	4509                	li	a0,2
    800065e2:	00a71623          	sh	a0,12(a4) # 200c <_entry-0x7fffdff4>
  disk[n].desc[idx[2]].next = 0;
    800065e6:	6298                	ld	a4,0(a3)
    800065e8:	963a                	add	a2,a2,a4
    800065ea:	00061723          	sh	zero,14(a2)

  // record struct buf for virtio_disk_intr().
  b->disk = 1;
    800065ee:	00ba2223          	sw	a1,4(s4)
  disk[n].info[idx[0]].b = b;
    800065f2:	0347b423          	sd	s4,40(a5)

  // avail[0] is flags
  // avail[1] tells the device how far to look in avail[2...].
  // avail[2...] are desc[] indices the device should process.
  // we only tell device the first index in our chain of descriptors.
  disk[n].avail[2 + (disk[n].avail[1] % NUM)] = idx[0];
    800065f6:	6698                	ld	a4,8(a3)
    800065f8:	00275783          	lhu	a5,2(a4)
    800065fc:	8b9d                	andi	a5,a5,7
    800065fe:	2789                	addiw	a5,a5,2
    80006600:	0786                	slli	a5,a5,0x1
    80006602:	97ba                	add	a5,a5,a4
    80006604:	00979023          	sh	s1,0(a5)
  __sync_synchronize();
    80006608:	0ff0000f          	fence
  disk[n].avail[1] = disk[n].avail[1] + 1;
    8000660c:	6698                	ld	a4,8(a3)
    8000660e:	00275783          	lhu	a5,2(a4)
    80006612:	2785                	addiw	a5,a5,1
    80006614:	00f71123          	sh	a5,2(a4)

  *R(n, VIRTIO_MMIO_QUEUE_NOTIFY) = 0; // value is queue number
    80006618:	0019079b          	addiw	a5,s2,1
    8000661c:	00c7979b          	slliw	a5,a5,0xc
    80006620:	10000737          	lui	a4,0x10000
    80006624:	05070713          	addi	a4,a4,80 # 10000050 <_entry-0x6fffffb0>
    80006628:	97ba                	add	a5,a5,a4
    8000662a:	0007a023          	sw	zero,0(a5)

  // Wait for virtio_disk_intr() to say request has finished.
  while(b->disk == 1) {
    8000662e:	004a2703          	lw	a4,4(s4)
    80006632:	4785                	li	a5,1
    80006634:	00f71d63          	bne	a4,a5,8000664e <virtio_disk_rw+0x274>
    80006638:	4485                	li	s1,1
    sleep(b, &disk[n].vdisk_lock);
    8000663a:	85ce                	mv	a1,s3
    8000663c:	8552                	mv	a0,s4
    8000663e:	ffffc097          	auipc	ra,0xffffc
    80006642:	da4080e7          	jalr	-604(ra) # 800023e2 <sleep>
  while(b->disk == 1) {
    80006646:	004a2783          	lw	a5,4(s4)
    8000664a:	fe9788e3          	beq	a5,s1,8000663a <virtio_disk_rw+0x260>
  }

  disk[n].info[idx[0]].b = 0;
    8000664e:	f8042483          	lw	s1,-128(s0)
    80006652:	00191793          	slli	a5,s2,0x1
    80006656:	97ca                	add	a5,a5,s2
    80006658:	07a2                	slli	a5,a5,0x8
    8000665a:	97a6                	add	a5,a5,s1
    8000665c:	20078793          	addi	a5,a5,512
    80006660:	0792                	slli	a5,a5,0x4
    80006662:	00024717          	auipc	a4,0x24
    80006666:	99e70713          	addi	a4,a4,-1634 # 8002a000 <disk>
    8000666a:	97ba                	add	a5,a5,a4
    8000666c:	0207b423          	sd	zero,40(a5)
    if(disk[n].desc[i].flags & VRING_DESC_F_NEXT)
    80006670:	00191793          	slli	a5,s2,0x1
    80006674:	97ca                	add	a5,a5,s2
    80006676:	07b2                	slli	a5,a5,0xc
    80006678:	97ba                	add	a5,a5,a4
    8000667a:	6a09                	lui	s4,0x2
    8000667c:	9a3e                	add	s4,s4,a5
    free_desc(n, i);
    8000667e:	85a6                	mv	a1,s1
    80006680:	854a                	mv	a0,s2
    80006682:	00000097          	auipc	ra,0x0
    80006686:	ad4080e7          	jalr	-1324(ra) # 80006156 <free_desc>
    if(disk[n].desc[i].flags & VRING_DESC_F_NEXT)
    8000668a:	0492                	slli	s1,s1,0x4
    8000668c:	000a3783          	ld	a5,0(s4) # 2000 <_entry-0x7fffe000>
    80006690:	94be                	add	s1,s1,a5
    80006692:	00c4d783          	lhu	a5,12(s1)
    80006696:	8b85                	andi	a5,a5,1
    80006698:	c78d                	beqz	a5,800066c2 <virtio_disk_rw+0x2e8>
      i = disk[n].desc[i].next;
    8000669a:	00e4d483          	lhu	s1,14(s1)
  while(1){
    8000669e:	b7c5                	j	8000667e <virtio_disk_rw+0x2a4>
    disk[n].desc[idx[1]].flags = VRING_DESC_F_WRITE; // device writes b->data
    800066a0:	00191793          	slli	a5,s2,0x1
    800066a4:	97ca                	add	a5,a5,s2
    800066a6:	07b2                	slli	a5,a5,0xc
    800066a8:	00024717          	auipc	a4,0x24
    800066ac:	95870713          	addi	a4,a4,-1704 # 8002a000 <disk>
    800066b0:	973e                	add	a4,a4,a5
    800066b2:	6789                	lui	a5,0x2
    800066b4:	97ba                	add	a5,a5,a4
    800066b6:	639c                	ld	a5,0(a5)
    800066b8:	97b2                	add	a5,a5,a2
    800066ba:	4709                	li	a4,2
    800066bc:	00e79623          	sh	a4,12(a5) # 200c <_entry-0x7fffdff4>
    800066c0:	bd4d                	j	80006572 <virtio_disk_rw+0x198>
  free_chain(n, idx[0]);

  release(&disk[n].vdisk_lock);
    800066c2:	854e                	mv	a0,s3
    800066c4:	ffffa097          	auipc	ra,0xffffa
    800066c8:	5f2080e7          	jalr	1522(ra) # 80000cb6 <release>
}
    800066cc:	60aa                	ld	ra,136(sp)
    800066ce:	640a                	ld	s0,128(sp)
    800066d0:	74e6                	ld	s1,120(sp)
    800066d2:	7946                	ld	s2,112(sp)
    800066d4:	79a6                	ld	s3,104(sp)
    800066d6:	7a06                	ld	s4,96(sp)
    800066d8:	6ae6                	ld	s5,88(sp)
    800066da:	6b46                	ld	s6,80(sp)
    800066dc:	6ba6                	ld	s7,72(sp)
    800066de:	6c06                	ld	s8,64(sp)
    800066e0:	7ce2                	ld	s9,56(sp)
    800066e2:	7d42                	ld	s10,48(sp)
    800066e4:	7da2                	ld	s11,40(sp)
    800066e6:	6149                	addi	sp,sp,144
    800066e8:	8082                	ret
  if(write)
    800066ea:	de0d9de3          	bnez	s11,800064e4 <virtio_disk_rw+0x10a>
    buf0.type = VIRTIO_BLK_T_IN; // read the disk
    800066ee:	f6042823          	sw	zero,-144(s0)
    800066f2:	bbe5                	j	800064ea <virtio_disk_rw+0x110>
      disk[n].free[i] = 0;
    800066f4:	000c0c23          	sb	zero,24(s8)
    idx[i] = alloc_desc(n);
    800066f8:	00072023          	sw	zero,0(a4)
    if(idx[i] < 0){
    800066fc:	b3ad                	j	80006466 <virtio_disk_rw+0x8c>

00000000800066fe <virtio_disk_intr>:

void
virtio_disk_intr(int n)
{
    800066fe:	7139                	addi	sp,sp,-64
    80006700:	fc06                	sd	ra,56(sp)
    80006702:	f822                	sd	s0,48(sp)
    80006704:	f426                	sd	s1,40(sp)
    80006706:	f04a                	sd	s2,32(sp)
    80006708:	ec4e                	sd	s3,24(sp)
    8000670a:	e852                	sd	s4,16(sp)
    8000670c:	e456                	sd	s5,8(sp)
    8000670e:	0080                	addi	s0,sp,64
    80006710:	84aa                	mv	s1,a0
  acquire(&disk[n].vdisk_lock);
    80006712:	00151913          	slli	s2,a0,0x1
    80006716:	00a90a33          	add	s4,s2,a0
    8000671a:	0a32                	slli	s4,s4,0xc
    8000671c:	6989                	lui	s3,0x2
    8000671e:	0b098793          	addi	a5,s3,176 # 20b0 <_entry-0x7fffdf50>
    80006722:	9a3e                	add	s4,s4,a5
    80006724:	00024a97          	auipc	s5,0x24
    80006728:	8dca8a93          	addi	s5,s5,-1828 # 8002a000 <disk>
    8000672c:	9a56                	add	s4,s4,s5
    8000672e:	8552                	mv	a0,s4
    80006730:	ffffa097          	auipc	ra,0xffffa
    80006734:	516080e7          	jalr	1302(ra) # 80000c46 <acquire>

  while((disk[n].used_idx % NUM) != (disk[n].used->id % NUM)){
    80006738:	9926                	add	s2,s2,s1
    8000673a:	0932                	slli	s2,s2,0xc
    8000673c:	9956                	add	s2,s2,s5
    8000673e:	99ca                	add	s3,s3,s2
    80006740:	0209d683          	lhu	a3,32(s3)
    80006744:	0109b703          	ld	a4,16(s3)
    80006748:	00275783          	lhu	a5,2(a4)
    8000674c:	8fb5                	xor	a5,a5,a3
    8000674e:	8b9d                	andi	a5,a5,7
    80006750:	cbd1                	beqz	a5,800067e4 <virtio_disk_intr+0xe6>
    int id = disk[n].used->elems[disk[n].used_idx].id;
    80006752:	068e                	slli	a3,a3,0x3
    80006754:	9736                	add	a4,a4,a3
    80006756:	435c                	lw	a5,4(a4)

    if(disk[n].info[id].status != 0)
    80006758:	00149713          	slli	a4,s1,0x1
    8000675c:	9726                	add	a4,a4,s1
    8000675e:	0722                	slli	a4,a4,0x8
    80006760:	973e                	add	a4,a4,a5
    80006762:	20070713          	addi	a4,a4,512
    80006766:	0712                	slli	a4,a4,0x4
    80006768:	9756                	add	a4,a4,s5
    8000676a:	03074703          	lbu	a4,48(a4)
    8000676e:	e33d                	bnez	a4,800067d4 <virtio_disk_intr+0xd6>
      panic("virtio_disk_intr status");
    
    disk[n].info[id].b->disk = 0;   // disk is done with buf
    80006770:	8956                	mv	s2,s5
    80006772:	00149713          	slli	a4,s1,0x1
    80006776:	9726                	add	a4,a4,s1
    80006778:	00871993          	slli	s3,a4,0x8
    wakeup(disk[n].info[id].b);

    disk[n].used_idx = (disk[n].used_idx + 1) % NUM;
    8000677c:	0732                	slli	a4,a4,0xc
    8000677e:	9756                	add	a4,a4,s5
    80006780:	6489                	lui	s1,0x2
    80006782:	94ba                	add	s1,s1,a4
    disk[n].info[id].b->disk = 0;   // disk is done with buf
    80006784:	97ce                	add	a5,a5,s3
    80006786:	20078793          	addi	a5,a5,512
    8000678a:	0792                	slli	a5,a5,0x4
    8000678c:	97ca                	add	a5,a5,s2
    8000678e:	7798                	ld	a4,40(a5)
    80006790:	00072223          	sw	zero,4(a4)
    wakeup(disk[n].info[id].b);
    80006794:	7788                	ld	a0,40(a5)
    80006796:	ffffc097          	auipc	ra,0xffffc
    8000679a:	dd2080e7          	jalr	-558(ra) # 80002568 <wakeup>
    disk[n].used_idx = (disk[n].used_idx + 1) % NUM;
    8000679e:	0204d783          	lhu	a5,32(s1) # 2020 <_entry-0x7fffdfe0>
    800067a2:	2785                	addiw	a5,a5,1
    800067a4:	8b9d                	andi	a5,a5,7
    800067a6:	03079613          	slli	a2,a5,0x30
    800067aa:	9241                	srli	a2,a2,0x30
    800067ac:	02c49023          	sh	a2,32(s1)
  while((disk[n].used_idx % NUM) != (disk[n].used->id % NUM)){
    800067b0:	6898                	ld	a4,16(s1)
    800067b2:	00275683          	lhu	a3,2(a4)
    800067b6:	8a9d                	andi	a3,a3,7
    800067b8:	02c68663          	beq	a3,a2,800067e4 <virtio_disk_intr+0xe6>
    int id = disk[n].used->elems[disk[n].used_idx].id;
    800067bc:	078e                	slli	a5,a5,0x3
    800067be:	97ba                	add	a5,a5,a4
    800067c0:	43dc                	lw	a5,4(a5)
    if(disk[n].info[id].status != 0)
    800067c2:	00f98733          	add	a4,s3,a5
    800067c6:	20070713          	addi	a4,a4,512
    800067ca:	0712                	slli	a4,a4,0x4
    800067cc:	974a                	add	a4,a4,s2
    800067ce:	03074703          	lbu	a4,48(a4)
    800067d2:	db4d                	beqz	a4,80006784 <virtio_disk_intr+0x86>
      panic("virtio_disk_intr status");
    800067d4:	00002517          	auipc	a0,0x2
    800067d8:	19c50513          	addi	a0,a0,412 # 80008970 <userret+0x8e0>
    800067dc:	ffffa097          	auipc	ra,0xffffa
    800067e0:	da2080e7          	jalr	-606(ra) # 8000057e <panic>
  }

  release(&disk[n].vdisk_lock);
    800067e4:	8552                	mv	a0,s4
    800067e6:	ffffa097          	auipc	ra,0xffffa
    800067ea:	4d0080e7          	jalr	1232(ra) # 80000cb6 <release>
}
    800067ee:	70e2                	ld	ra,56(sp)
    800067f0:	7442                	ld	s0,48(sp)
    800067f2:	74a2                	ld	s1,40(sp)
    800067f4:	7902                	ld	s2,32(sp)
    800067f6:	69e2                	ld	s3,24(sp)
    800067f8:	6a42                	ld	s4,16(sp)
    800067fa:	6aa2                	ld	s5,8(sp)
    800067fc:	6121                	addi	sp,sp,64
    800067fe:	8082                	ret

0000000080006800 <bit_isset>:
static Sz_info *bd_sizes; 
static void *bd_base;   // start address of memory managed by the buddy allocator
static struct spinlock lock;

// Return 1 if bit at position index in array is set to 1
int bit_isset(char *array, int index) {
    80006800:	1141                	addi	sp,sp,-16
    80006802:	e422                	sd	s0,8(sp)
    80006804:	0800                	addi	s0,sp,16
  char b = array[index/8];
  char m = (1 << (index % 8));
    80006806:	41f5d79b          	sraiw	a5,a1,0x1f
    8000680a:	01d7d79b          	srliw	a5,a5,0x1d
    8000680e:	9dbd                	addw	a1,a1,a5
    80006810:	0075f713          	andi	a4,a1,7
    80006814:	9f1d                	subw	a4,a4,a5
    80006816:	4785                	li	a5,1
    80006818:	00e797bb          	sllw	a5,a5,a4
    8000681c:	0ff7f793          	andi	a5,a5,255
  char b = array[index/8];
    80006820:	4035d59b          	sraiw	a1,a1,0x3
    80006824:	95aa                	add	a1,a1,a0
  return (b & m) == m;
    80006826:	0005c503          	lbu	a0,0(a1)
    8000682a:	8d7d                	and	a0,a0,a5
    8000682c:	8d1d                	sub	a0,a0,a5
}
    8000682e:	00153513          	seqz	a0,a0
    80006832:	6422                	ld	s0,8(sp)
    80006834:	0141                	addi	sp,sp,16
    80006836:	8082                	ret

0000000080006838 <bit_set>:

// Set bit at position index in array to 1
void bit_set(char *array, int index) {
    80006838:	1141                	addi	sp,sp,-16
    8000683a:	e422                	sd	s0,8(sp)
    8000683c:	0800                	addi	s0,sp,16
  char b = array[index/8];
    8000683e:	41f5d71b          	sraiw	a4,a1,0x1f
    80006842:	01d7571b          	srliw	a4,a4,0x1d
    80006846:	9db9                	addw	a1,a1,a4
    80006848:	4035d79b          	sraiw	a5,a1,0x3
    8000684c:	953e                	add	a0,a0,a5
  char m = (1 << (index % 8));
    8000684e:	899d                	andi	a1,a1,7
    80006850:	9d99                	subw	a1,a1,a4
  array[index/8] = (b | m);
    80006852:	4785                	li	a5,1
    80006854:	00b795bb          	sllw	a1,a5,a1
    80006858:	00054783          	lbu	a5,0(a0)
    8000685c:	8ddd                	or	a1,a1,a5
    8000685e:	00b50023          	sb	a1,0(a0)
}
    80006862:	6422                	ld	s0,8(sp)
    80006864:	0141                	addi	sp,sp,16
    80006866:	8082                	ret

0000000080006868 <bit_clear>:

// Clear bit at position index in array
void bit_clear(char *array, int index) {
    80006868:	1141                	addi	sp,sp,-16
    8000686a:	e422                	sd	s0,8(sp)
    8000686c:	0800                	addi	s0,sp,16
  char b = array[index/8];
    8000686e:	41f5d71b          	sraiw	a4,a1,0x1f
    80006872:	01d7571b          	srliw	a4,a4,0x1d
    80006876:	9db9                	addw	a1,a1,a4
    80006878:	4035d79b          	sraiw	a5,a1,0x3
    8000687c:	953e                	add	a0,a0,a5
  char m = (1 << (index % 8));
    8000687e:	899d                	andi	a1,a1,7
    80006880:	9d99                	subw	a1,a1,a4
  array[index/8] = (b & ~m);
    80006882:	4785                	li	a5,1
    80006884:	00b795bb          	sllw	a1,a5,a1
    80006888:	fff5c593          	not	a1,a1
    8000688c:	00054783          	lbu	a5,0(a0)
    80006890:	8dfd                	and	a1,a1,a5
    80006892:	00b50023          	sb	a1,0(a0)
}
    80006896:	6422                	ld	s0,8(sp)
    80006898:	0141                	addi	sp,sp,16
    8000689a:	8082                	ret

000000008000689c <bd_print_vector>:

// Print a bit vector as a list of ranges of 1 bits
void
bd_print_vector(char *vector, int len) {
    8000689c:	715d                	addi	sp,sp,-80
    8000689e:	e486                	sd	ra,72(sp)
    800068a0:	e0a2                	sd	s0,64(sp)
    800068a2:	fc26                	sd	s1,56(sp)
    800068a4:	f84a                	sd	s2,48(sp)
    800068a6:	f44e                	sd	s3,40(sp)
    800068a8:	f052                	sd	s4,32(sp)
    800068aa:	ec56                	sd	s5,24(sp)
    800068ac:	e85a                	sd	s6,16(sp)
    800068ae:	e45e                	sd	s7,8(sp)
    800068b0:	0880                	addi	s0,sp,80
    800068b2:	8a2e                	mv	s4,a1
  int last, lb;
  
  last = 1;
  lb = 0;
  for (int b = 0; b < len; b++) {
    800068b4:	08b05b63          	blez	a1,8000694a <bd_print_vector+0xae>
    800068b8:	89aa                	mv	s3,a0
    800068ba:	4481                	li	s1,0
  lb = 0;
    800068bc:	4a81                	li	s5,0
  last = 1;
    800068be:	4905                	li	s2,1
    if (last == bit_isset(vector, b))
      continue;
    if(last == 1)
    800068c0:	4b05                	li	s6,1
      printf(" [%d, %d)", lb, b);
    800068c2:	00002b97          	auipc	s7,0x2
    800068c6:	0c6b8b93          	addi	s7,s7,198 # 80008988 <userret+0x8f8>
    800068ca:	a01d                	j	800068f0 <bd_print_vector+0x54>
    800068cc:	8626                	mv	a2,s1
    800068ce:	85d6                	mv	a1,s5
    800068d0:	855e                	mv	a0,s7
    800068d2:	ffffa097          	auipc	ra,0xffffa
    800068d6:	d06080e7          	jalr	-762(ra) # 800005d8 <printf>
    lb = b;
    last = bit_isset(vector, b);
    800068da:	85a6                	mv	a1,s1
    800068dc:	854e                	mv	a0,s3
    800068de:	00000097          	auipc	ra,0x0
    800068e2:	f22080e7          	jalr	-222(ra) # 80006800 <bit_isset>
    800068e6:	892a                	mv	s2,a0
    800068e8:	8aa6                	mv	s5,s1
  for (int b = 0; b < len; b++) {
    800068ea:	2485                	addiw	s1,s1,1
    800068ec:	009a0d63          	beq	s4,s1,80006906 <bd_print_vector+0x6a>
    if (last == bit_isset(vector, b))
    800068f0:	85a6                	mv	a1,s1
    800068f2:	854e                	mv	a0,s3
    800068f4:	00000097          	auipc	ra,0x0
    800068f8:	f0c080e7          	jalr	-244(ra) # 80006800 <bit_isset>
    800068fc:	ff2507e3          	beq	a0,s2,800068ea <bd_print_vector+0x4e>
    if(last == 1)
    80006900:	fd691de3          	bne	s2,s6,800068da <bd_print_vector+0x3e>
    80006904:	b7e1                	j	800068cc <bd_print_vector+0x30>
  }
  if(lb == 0 || last == 1) {
    80006906:	000a8563          	beqz	s5,80006910 <bd_print_vector+0x74>
    8000690a:	4785                	li	a5,1
    8000690c:	00f91c63          	bne	s2,a5,80006924 <bd_print_vector+0x88>
    printf(" [%d, %d)", lb, len);
    80006910:	8652                	mv	a2,s4
    80006912:	85d6                	mv	a1,s5
    80006914:	00002517          	auipc	a0,0x2
    80006918:	07450513          	addi	a0,a0,116 # 80008988 <userret+0x8f8>
    8000691c:	ffffa097          	auipc	ra,0xffffa
    80006920:	cbc080e7          	jalr	-836(ra) # 800005d8 <printf>
  }
  printf("\n");
    80006924:	00002517          	auipc	a0,0x2
    80006928:	96c50513          	addi	a0,a0,-1684 # 80008290 <userret+0x200>
    8000692c:	ffffa097          	auipc	ra,0xffffa
    80006930:	cac080e7          	jalr	-852(ra) # 800005d8 <printf>
}
    80006934:	60a6                	ld	ra,72(sp)
    80006936:	6406                	ld	s0,64(sp)
    80006938:	74e2                	ld	s1,56(sp)
    8000693a:	7942                	ld	s2,48(sp)
    8000693c:	79a2                	ld	s3,40(sp)
    8000693e:	7a02                	ld	s4,32(sp)
    80006940:	6ae2                	ld	s5,24(sp)
    80006942:	6b42                	ld	s6,16(sp)
    80006944:	6ba2                	ld	s7,8(sp)
    80006946:	6161                	addi	sp,sp,80
    80006948:	8082                	ret
  lb = 0;
    8000694a:	4a81                	li	s5,0
    8000694c:	b7d1                	j	80006910 <bd_print_vector+0x74>

000000008000694e <bd_print>:

// Print buddy's data structures
void
bd_print() {
  for (int k = 0; k < nsizes; k++) {
    8000694e:	00029797          	auipc	a5,0x29
    80006952:	70a78793          	addi	a5,a5,1802 # 80030058 <nsizes>
    80006956:	4394                	lw	a3,0(a5)
    80006958:	0ed05b63          	blez	a3,80006a4e <bd_print+0x100>
bd_print() {
    8000695c:	711d                	addi	sp,sp,-96
    8000695e:	ec86                	sd	ra,88(sp)
    80006960:	e8a2                	sd	s0,80(sp)
    80006962:	e4a6                	sd	s1,72(sp)
    80006964:	e0ca                	sd	s2,64(sp)
    80006966:	fc4e                	sd	s3,56(sp)
    80006968:	f852                	sd	s4,48(sp)
    8000696a:	f456                	sd	s5,40(sp)
    8000696c:	f05a                	sd	s6,32(sp)
    8000696e:	ec5e                	sd	s7,24(sp)
    80006970:	e862                	sd	s8,16(sp)
    80006972:	e466                	sd	s9,8(sp)
    80006974:	e06a                	sd	s10,0(sp)
    80006976:	1080                	addi	s0,sp,96
  for (int k = 0; k < nsizes; k++) {
    80006978:	4901                	li	s2,0
    printf("size %d (blksz %d nblk %d): free list: ", k, BLK_SIZE(k), NBLK(k));
    8000697a:	4a85                	li	s5,1
    8000697c:	4c41                	li	s8,16
    8000697e:	00002b97          	auipc	s7,0x2
    80006982:	01ab8b93          	addi	s7,s7,26 # 80008998 <userret+0x908>
    lst_print(&bd_sizes[k].free);
    80006986:	00029a17          	auipc	s4,0x29
    8000698a:	6caa0a13          	addi	s4,s4,1738 # 80030050 <bd_sizes>
    printf("  alloc:");
    8000698e:	00002b17          	auipc	s6,0x2
    80006992:	032b0b13          	addi	s6,s6,50 # 800089c0 <userret+0x930>
    bd_print_vector(bd_sizes[k].alloc, NBLK(k));
    80006996:	89be                	mv	s3,a5
    if(k > 0) {
      printf("  split:");
    80006998:	00002c97          	auipc	s9,0x2
    8000699c:	038c8c93          	addi	s9,s9,56 # 800089d0 <userret+0x940>
    800069a0:	a801                	j	800069b0 <bd_print+0x62>
  for (int k = 0; k < nsizes; k++) {
    800069a2:	0009a683          	lw	a3,0(s3)
    800069a6:	0905                	addi	s2,s2,1
    800069a8:	0009079b          	sext.w	a5,s2
    800069ac:	08d7d363          	ble	a3,a5,80006a32 <bd_print+0xe4>
    800069b0:	0009049b          	sext.w	s1,s2
    printf("size %d (blksz %d nblk %d): free list: ", k, BLK_SIZE(k), NBLK(k));
    800069b4:	36fd                	addiw	a3,a3,-1
    800069b6:	9e85                	subw	a3,a3,s1
    800069b8:	00da96bb          	sllw	a3,s5,a3
    800069bc:	009c1633          	sll	a2,s8,s1
    800069c0:	85a6                	mv	a1,s1
    800069c2:	855e                	mv	a0,s7
    800069c4:	ffffa097          	auipc	ra,0xffffa
    800069c8:	c14080e7          	jalr	-1004(ra) # 800005d8 <printf>
    lst_print(&bd_sizes[k].free);
    800069cc:	00591d13          	slli	s10,s2,0x5
    800069d0:	000a3503          	ld	a0,0(s4)
    800069d4:	956a                	add	a0,a0,s10
    800069d6:	00001097          	auipc	ra,0x1
    800069da:	a80080e7          	jalr	-1408(ra) # 80007456 <lst_print>
    printf("  alloc:");
    800069de:	855a                	mv	a0,s6
    800069e0:	ffffa097          	auipc	ra,0xffffa
    800069e4:	bf8080e7          	jalr	-1032(ra) # 800005d8 <printf>
    bd_print_vector(bd_sizes[k].alloc, NBLK(k));
    800069e8:	0009a583          	lw	a1,0(s3)
    800069ec:	35fd                	addiw	a1,a1,-1
    800069ee:	9d85                	subw	a1,a1,s1
    800069f0:	000a3783          	ld	a5,0(s4)
    800069f4:	97ea                	add	a5,a5,s10
    800069f6:	00ba95bb          	sllw	a1,s5,a1
    800069fa:	6b88                	ld	a0,16(a5)
    800069fc:	00000097          	auipc	ra,0x0
    80006a00:	ea0080e7          	jalr	-352(ra) # 8000689c <bd_print_vector>
    if(k > 0) {
    80006a04:	f8905fe3          	blez	s1,800069a2 <bd_print+0x54>
      printf("  split:");
    80006a08:	8566                	mv	a0,s9
    80006a0a:	ffffa097          	auipc	ra,0xffffa
    80006a0e:	bce080e7          	jalr	-1074(ra) # 800005d8 <printf>
      bd_print_vector(bd_sizes[k].split, NBLK(k));
    80006a12:	0009a583          	lw	a1,0(s3)
    80006a16:	35fd                	addiw	a1,a1,-1
    80006a18:	9d85                	subw	a1,a1,s1
    80006a1a:	000a3783          	ld	a5,0(s4)
    80006a1e:	9d3e                	add	s10,s10,a5
    80006a20:	00ba95bb          	sllw	a1,s5,a1
    80006a24:	018d3503          	ld	a0,24(s10) # 1018 <_entry-0x7fffefe8>
    80006a28:	00000097          	auipc	ra,0x0
    80006a2c:	e74080e7          	jalr	-396(ra) # 8000689c <bd_print_vector>
    80006a30:	bf8d                	j	800069a2 <bd_print+0x54>
    }
  }
}
    80006a32:	60e6                	ld	ra,88(sp)
    80006a34:	6446                	ld	s0,80(sp)
    80006a36:	64a6                	ld	s1,72(sp)
    80006a38:	6906                	ld	s2,64(sp)
    80006a3a:	79e2                	ld	s3,56(sp)
    80006a3c:	7a42                	ld	s4,48(sp)
    80006a3e:	7aa2                	ld	s5,40(sp)
    80006a40:	7b02                	ld	s6,32(sp)
    80006a42:	6be2                	ld	s7,24(sp)
    80006a44:	6c42                	ld	s8,16(sp)
    80006a46:	6ca2                	ld	s9,8(sp)
    80006a48:	6d02                	ld	s10,0(sp)
    80006a4a:	6125                	addi	sp,sp,96
    80006a4c:	8082                	ret
    80006a4e:	8082                	ret

0000000080006a50 <firstk>:

// What is the first k such that 2^k >= n?
int
firstk(uint64 n) {
    80006a50:	1141                	addi	sp,sp,-16
    80006a52:	e422                	sd	s0,8(sp)
    80006a54:	0800                	addi	s0,sp,16
  int k = 0;
  uint64 size = LEAF_SIZE;

  while (size < n) {
    80006a56:	47c1                	li	a5,16
    80006a58:	00a7fb63          	bleu	a0,a5,80006a6e <firstk+0x1e>
  int k = 0;
    80006a5c:	4701                	li	a4,0
    k++;
    80006a5e:	2705                	addiw	a4,a4,1
    size *= 2;
    80006a60:	0786                	slli	a5,a5,0x1
  while (size < n) {
    80006a62:	fea7eee3          	bltu	a5,a0,80006a5e <firstk+0xe>
  }
  return k;
}
    80006a66:	853a                	mv	a0,a4
    80006a68:	6422                	ld	s0,8(sp)
    80006a6a:	0141                	addi	sp,sp,16
    80006a6c:	8082                	ret
  int k = 0;
    80006a6e:	4701                	li	a4,0
    80006a70:	bfdd                	j	80006a66 <firstk+0x16>

0000000080006a72 <blk_index>:

// Compute the block index for address p at size k
int
blk_index(int k, char *p) {
    80006a72:	1141                	addi	sp,sp,-16
    80006a74:	e422                	sd	s0,8(sp)
    80006a76:	0800                	addi	s0,sp,16
  int n = p - (char *) bd_base;
    80006a78:	00029797          	auipc	a5,0x29
    80006a7c:	5d078793          	addi	a5,a5,1488 # 80030048 <bd_base>
    80006a80:	639c                	ld	a5,0(a5)
  return n / BLK_SIZE(k);
    80006a82:	9d9d                	subw	a1,a1,a5
    80006a84:	47c1                	li	a5,16
    80006a86:	00a79533          	sll	a0,a5,a0
    80006a8a:	02a5c533          	div	a0,a1,a0
}
    80006a8e:	2501                	sext.w	a0,a0
    80006a90:	6422                	ld	s0,8(sp)
    80006a92:	0141                	addi	sp,sp,16
    80006a94:	8082                	ret

0000000080006a96 <addr>:

// Convert a block index at size k back into an address
void *addr(int k, int bi) {
    80006a96:	1141                	addi	sp,sp,-16
    80006a98:	e422                	sd	s0,8(sp)
    80006a9a:	0800                	addi	s0,sp,16
  int n = bi * BLK_SIZE(k);
    80006a9c:	47c1                	li	a5,16
    80006a9e:	00a79533          	sll	a0,a5,a0
  return (char *) bd_base + n;
    80006aa2:	02a5853b          	mulw	a0,a1,a0
    80006aa6:	00029797          	auipc	a5,0x29
    80006aaa:	5a278793          	addi	a5,a5,1442 # 80030048 <bd_base>
    80006aae:	639c                	ld	a5,0(a5)
}
    80006ab0:	953e                	add	a0,a0,a5
    80006ab2:	6422                	ld	s0,8(sp)
    80006ab4:	0141                	addi	sp,sp,16
    80006ab6:	8082                	ret

0000000080006ab8 <bd_malloc>:

// allocate nbytes, but malloc won't return anything smaller than LEAF_SIZE
void *
bd_malloc(uint64 nbytes)
{
    80006ab8:	7159                	addi	sp,sp,-112
    80006aba:	f486                	sd	ra,104(sp)
    80006abc:	f0a2                	sd	s0,96(sp)
    80006abe:	eca6                	sd	s1,88(sp)
    80006ac0:	e8ca                	sd	s2,80(sp)
    80006ac2:	e4ce                	sd	s3,72(sp)
    80006ac4:	e0d2                	sd	s4,64(sp)
    80006ac6:	fc56                	sd	s5,56(sp)
    80006ac8:	f85a                	sd	s6,48(sp)
    80006aca:	f45e                	sd	s7,40(sp)
    80006acc:	f062                	sd	s8,32(sp)
    80006ace:	ec66                	sd	s9,24(sp)
    80006ad0:	e86a                	sd	s10,16(sp)
    80006ad2:	e46e                	sd	s11,8(sp)
    80006ad4:	1880                	addi	s0,sp,112
    80006ad6:	84aa                	mv	s1,a0
  int fk, k;

  acquire(&lock);
    80006ad8:	00029517          	auipc	a0,0x29
    80006adc:	52850513          	addi	a0,a0,1320 # 80030000 <lock>
    80006ae0:	ffffa097          	auipc	ra,0xffffa
    80006ae4:	166080e7          	jalr	358(ra) # 80000c46 <acquire>

  // Find a free block >= nbytes, starting with smallest k possible
  fk = firstk(nbytes);
    80006ae8:	8526                	mv	a0,s1
    80006aea:	00000097          	auipc	ra,0x0
    80006aee:	f66080e7          	jalr	-154(ra) # 80006a50 <firstk>
  for (k = fk; k < nsizes; k++) {
    80006af2:	00029797          	auipc	a5,0x29
    80006af6:	56678793          	addi	a5,a5,1382 # 80030058 <nsizes>
    80006afa:	439c                	lw	a5,0(a5)
    80006afc:	02f55d63          	ble	a5,a0,80006b36 <bd_malloc+0x7e>
    80006b00:	8d2a                	mv	s10,a0
    80006b02:	00551913          	slli	s2,a0,0x5
    80006b06:	84aa                	mv	s1,a0
    if(!lst_empty(&bd_sizes[k].free))
    80006b08:	00029997          	auipc	s3,0x29
    80006b0c:	54898993          	addi	s3,s3,1352 # 80030050 <bd_sizes>
  for (k = fk; k < nsizes; k++) {
    80006b10:	00029a17          	auipc	s4,0x29
    80006b14:	548a0a13          	addi	s4,s4,1352 # 80030058 <nsizes>
    if(!lst_empty(&bd_sizes[k].free))
    80006b18:	0009b503          	ld	a0,0(s3)
    80006b1c:	954a                	add	a0,a0,s2
    80006b1e:	00001097          	auipc	ra,0x1
    80006b22:	8be080e7          	jalr	-1858(ra) # 800073dc <lst_empty>
    80006b26:	c115                	beqz	a0,80006b4a <bd_malloc+0x92>
  for (k = fk; k < nsizes; k++) {
    80006b28:	2485                	addiw	s1,s1,1
    80006b2a:	02090913          	addi	s2,s2,32
    80006b2e:	000a2783          	lw	a5,0(s4)
    80006b32:	fef4c3e3          	blt	s1,a5,80006b18 <bd_malloc+0x60>
      break;
  }
  if(k >= nsizes) { // No free blocks?
    release(&lock);
    80006b36:	00029517          	auipc	a0,0x29
    80006b3a:	4ca50513          	addi	a0,a0,1226 # 80030000 <lock>
    80006b3e:	ffffa097          	auipc	ra,0xffffa
    80006b42:	178080e7          	jalr	376(ra) # 80000cb6 <release>
    return 0;
    80006b46:	4b81                	li	s7,0
    80006b48:	a8d1                	j	80006c1c <bd_malloc+0x164>
  if(k >= nsizes) { // No free blocks?
    80006b4a:	00029797          	auipc	a5,0x29
    80006b4e:	50e78793          	addi	a5,a5,1294 # 80030058 <nsizes>
    80006b52:	439c                	lw	a5,0(a5)
    80006b54:	fef4d1e3          	ble	a5,s1,80006b36 <bd_malloc+0x7e>
  }

  // Found a block; pop it and potentially split it.
  char *p = lst_pop(&bd_sizes[k].free);
    80006b58:	00549993          	slli	s3,s1,0x5
    80006b5c:	00029917          	auipc	s2,0x29
    80006b60:	4f490913          	addi	s2,s2,1268 # 80030050 <bd_sizes>
    80006b64:	00093503          	ld	a0,0(s2)
    80006b68:	954e                	add	a0,a0,s3
    80006b6a:	00001097          	auipc	ra,0x1
    80006b6e:	89e080e7          	jalr	-1890(ra) # 80007408 <lst_pop>
    80006b72:	8baa                	mv	s7,a0
  int n = p - (char *) bd_base;
    80006b74:	00029797          	auipc	a5,0x29
    80006b78:	4d478793          	addi	a5,a5,1236 # 80030048 <bd_base>
    80006b7c:	638c                	ld	a1,0(a5)
  return n / BLK_SIZE(k);
    80006b7e:	40b505bb          	subw	a1,a0,a1
    80006b82:	47c1                	li	a5,16
    80006b84:	009797b3          	sll	a5,a5,s1
    80006b88:	02f5c5b3          	div	a1,a1,a5
  bit_set(bd_sizes[k].alloc, blk_index(k, p));
    80006b8c:	00093783          	ld	a5,0(s2)
    80006b90:	97ce                	add	a5,a5,s3
    80006b92:	2581                	sext.w	a1,a1
    80006b94:	6b88                	ld	a0,16(a5)
    80006b96:	00000097          	auipc	ra,0x0
    80006b9a:	ca2080e7          	jalr	-862(ra) # 80006838 <bit_set>
  for(; k > fk; k--) {
    80006b9e:	069d5763          	ble	s1,s10,80006c0c <bd_malloc+0x154>
    // split a block at size k and mark one half allocated at size k-1
    // and put the buddy on the free list at size k-1
    char *q = p + BLK_SIZE(k-1);   // p's buddy
    80006ba2:	4c41                	li	s8,16
  int n = p - (char *) bd_base;
    80006ba4:	00029d97          	auipc	s11,0x29
    80006ba8:	4a4d8d93          	addi	s11,s11,1188 # 80030048 <bd_base>
    char *q = p + BLK_SIZE(k-1);   // p's buddy
    80006bac:	fff48a9b          	addiw	s5,s1,-1
    80006bb0:	015c1b33          	sll	s6,s8,s5
    80006bb4:	016b8cb3          	add	s9,s7,s6
    bit_set(bd_sizes[k].split, blk_index(k, p));
    80006bb8:	00029797          	auipc	a5,0x29
    80006bbc:	49878793          	addi	a5,a5,1176 # 80030050 <bd_sizes>
    80006bc0:	0007ba03          	ld	s4,0(a5)
  int n = p - (char *) bd_base;
    80006bc4:	000db903          	ld	s2,0(s11)
  return n / BLK_SIZE(k);
    80006bc8:	412b893b          	subw	s2,s7,s2
    80006bcc:	009c15b3          	sll	a1,s8,s1
    80006bd0:	02b945b3          	div	a1,s2,a1
    bit_set(bd_sizes[k].split, blk_index(k, p));
    80006bd4:	013a07b3          	add	a5,s4,s3
    80006bd8:	2581                	sext.w	a1,a1
    80006bda:	6f88                	ld	a0,24(a5)
    80006bdc:	00000097          	auipc	ra,0x0
    80006be0:	c5c080e7          	jalr	-932(ra) # 80006838 <bit_set>
    bit_set(bd_sizes[k-1].alloc, blk_index(k-1, p));
    80006be4:	1981                	addi	s3,s3,-32
    80006be6:	9a4e                	add	s4,s4,s3
  return n / BLK_SIZE(k);
    80006be8:	036945b3          	div	a1,s2,s6
    bit_set(bd_sizes[k-1].alloc, blk_index(k-1, p));
    80006bec:	2581                	sext.w	a1,a1
    80006bee:	010a3503          	ld	a0,16(s4)
    80006bf2:	00000097          	auipc	ra,0x0
    80006bf6:	c46080e7          	jalr	-954(ra) # 80006838 <bit_set>
    lst_push(&bd_sizes[k-1].free, q);
    80006bfa:	85e6                	mv	a1,s9
    80006bfc:	8552                	mv	a0,s4
    80006bfe:	00001097          	auipc	ra,0x1
    80006c02:	840080e7          	jalr	-1984(ra) # 8000743e <lst_push>
  for(; k > fk; k--) {
    80006c06:	84d6                	mv	s1,s5
    80006c08:	fbaa92e3          	bne	s5,s10,80006bac <bd_malloc+0xf4>
  }
  release(&lock);
    80006c0c:	00029517          	auipc	a0,0x29
    80006c10:	3f450513          	addi	a0,a0,1012 # 80030000 <lock>
    80006c14:	ffffa097          	auipc	ra,0xffffa
    80006c18:	0a2080e7          	jalr	162(ra) # 80000cb6 <release>

  return p;
}
    80006c1c:	855e                	mv	a0,s7
    80006c1e:	70a6                	ld	ra,104(sp)
    80006c20:	7406                	ld	s0,96(sp)
    80006c22:	64e6                	ld	s1,88(sp)
    80006c24:	6946                	ld	s2,80(sp)
    80006c26:	69a6                	ld	s3,72(sp)
    80006c28:	6a06                	ld	s4,64(sp)
    80006c2a:	7ae2                	ld	s5,56(sp)
    80006c2c:	7b42                	ld	s6,48(sp)
    80006c2e:	7ba2                	ld	s7,40(sp)
    80006c30:	7c02                	ld	s8,32(sp)
    80006c32:	6ce2                	ld	s9,24(sp)
    80006c34:	6d42                	ld	s10,16(sp)
    80006c36:	6da2                	ld	s11,8(sp)
    80006c38:	6165                	addi	sp,sp,112
    80006c3a:	8082                	ret

0000000080006c3c <size>:

// Find the size of the block that p points to.
int
size(char *p) {
    80006c3c:	7139                	addi	sp,sp,-64
    80006c3e:	fc06                	sd	ra,56(sp)
    80006c40:	f822                	sd	s0,48(sp)
    80006c42:	f426                	sd	s1,40(sp)
    80006c44:	f04a                	sd	s2,32(sp)
    80006c46:	ec4e                	sd	s3,24(sp)
    80006c48:	e852                	sd	s4,16(sp)
    80006c4a:	e456                	sd	s5,8(sp)
    80006c4c:	e05a                	sd	s6,0(sp)
    80006c4e:	0080                	addi	s0,sp,64
  for (int k = 0; k < nsizes; k++) {
    80006c50:	00029797          	auipc	a5,0x29
    80006c54:	40878793          	addi	a5,a5,1032 # 80030058 <nsizes>
    80006c58:	0007aa83          	lw	s5,0(a5)
  int n = p - (char *) bd_base;
    80006c5c:	00029797          	auipc	a5,0x29
    80006c60:	3ec78793          	addi	a5,a5,1004 # 80030048 <bd_base>
    80006c64:	0007ba03          	ld	s4,0(a5)
  return n / BLK_SIZE(k);
    80006c68:	41450a3b          	subw	s4,a0,s4
    if(bit_isset(bd_sizes[k+1].split, blk_index(k+1, p))) {
    80006c6c:	00029797          	auipc	a5,0x29
    80006c70:	3e478793          	addi	a5,a5,996 # 80030050 <bd_sizes>
    80006c74:	6384                	ld	s1,0(a5)
    80006c76:	03848493          	addi	s1,s1,56
  for (int k = 0; k < nsizes; k++) {
    80006c7a:	4901                	li	s2,0
  return n / BLK_SIZE(k);
    80006c7c:	4b41                	li	s6,16
  for (int k = 0; k < nsizes; k++) {
    80006c7e:	03595363          	ble	s5,s2,80006ca4 <size+0x68>
    if(bit_isset(bd_sizes[k+1].split, blk_index(k+1, p))) {
    80006c82:	0019099b          	addiw	s3,s2,1
  return n / BLK_SIZE(k);
    80006c86:	013b15b3          	sll	a1,s6,s3
    80006c8a:	02ba45b3          	div	a1,s4,a1
    if(bit_isset(bd_sizes[k+1].split, blk_index(k+1, p))) {
    80006c8e:	2581                	sext.w	a1,a1
    80006c90:	6088                	ld	a0,0(s1)
    80006c92:	00000097          	auipc	ra,0x0
    80006c96:	b6e080e7          	jalr	-1170(ra) # 80006800 <bit_isset>
    80006c9a:	02048493          	addi	s1,s1,32
    80006c9e:	e501                	bnez	a0,80006ca6 <size+0x6a>
  for (int k = 0; k < nsizes; k++) {
    80006ca0:	894e                	mv	s2,s3
    80006ca2:	bff1                	j	80006c7e <size+0x42>
      return k;
    }
  }
  return 0;
    80006ca4:	4901                	li	s2,0
}
    80006ca6:	854a                	mv	a0,s2
    80006ca8:	70e2                	ld	ra,56(sp)
    80006caa:	7442                	ld	s0,48(sp)
    80006cac:	74a2                	ld	s1,40(sp)
    80006cae:	7902                	ld	s2,32(sp)
    80006cb0:	69e2                	ld	s3,24(sp)
    80006cb2:	6a42                	ld	s4,16(sp)
    80006cb4:	6aa2                	ld	s5,8(sp)
    80006cb6:	6b02                	ld	s6,0(sp)
    80006cb8:	6121                	addi	sp,sp,64
    80006cba:	8082                	ret

0000000080006cbc <bd_free>:

// Free memory pointed to by p, which was earlier allocated using
// bd_malloc.
void
bd_free(void *p) {
    80006cbc:	7159                	addi	sp,sp,-112
    80006cbe:	f486                	sd	ra,104(sp)
    80006cc0:	f0a2                	sd	s0,96(sp)
    80006cc2:	eca6                	sd	s1,88(sp)
    80006cc4:	e8ca                	sd	s2,80(sp)
    80006cc6:	e4ce                	sd	s3,72(sp)
    80006cc8:	e0d2                	sd	s4,64(sp)
    80006cca:	fc56                	sd	s5,56(sp)
    80006ccc:	f85a                	sd	s6,48(sp)
    80006cce:	f45e                	sd	s7,40(sp)
    80006cd0:	f062                	sd	s8,32(sp)
    80006cd2:	ec66                	sd	s9,24(sp)
    80006cd4:	e86a                	sd	s10,16(sp)
    80006cd6:	e46e                	sd	s11,8(sp)
    80006cd8:	1880                	addi	s0,sp,112
    80006cda:	8b2a                	mv	s6,a0
  void *q;
  int k;

  acquire(&lock);
    80006cdc:	00029517          	auipc	a0,0x29
    80006ce0:	32450513          	addi	a0,a0,804 # 80030000 <lock>
    80006ce4:	ffffa097          	auipc	ra,0xffffa
    80006ce8:	f62080e7          	jalr	-158(ra) # 80000c46 <acquire>
  for (k = size(p); k < MAXSIZE; k++) {
    80006cec:	855a                	mv	a0,s6
    80006cee:	00000097          	auipc	ra,0x0
    80006cf2:	f4e080e7          	jalr	-178(ra) # 80006c3c <size>
    80006cf6:	892a                	mv	s2,a0
    80006cf8:	00029797          	auipc	a5,0x29
    80006cfc:	36078793          	addi	a5,a5,864 # 80030058 <nsizes>
    80006d00:	439c                	lw	a5,0(a5)
    80006d02:	37fd                	addiw	a5,a5,-1
    80006d04:	0af55a63          	ble	a5,a0,80006db8 <bd_free+0xfc>
    80006d08:	00551a93          	slli	s5,a0,0x5
  int n = p - (char *) bd_base;
    80006d0c:	00029c97          	auipc	s9,0x29
    80006d10:	33cc8c93          	addi	s9,s9,828 # 80030048 <bd_base>
  return n / BLK_SIZE(k);
    80006d14:	4c41                	li	s8,16
    int bi = blk_index(k, p);
    int buddy = (bi % 2 == 0) ? bi+1 : bi-1;
    bit_clear(bd_sizes[k].alloc, bi);  // free p at size k
    80006d16:	00029b97          	auipc	s7,0x29
    80006d1a:	33ab8b93          	addi	s7,s7,826 # 80030050 <bd_sizes>
  for (k = size(p); k < MAXSIZE; k++) {
    80006d1e:	00029d17          	auipc	s10,0x29
    80006d22:	33ad0d13          	addi	s10,s10,826 # 80030058 <nsizes>
    80006d26:	a82d                	j	80006d60 <bd_free+0xa4>
    int buddy = (bi % 2 == 0) ? bi+1 : bi-1;
    80006d28:	fff5849b          	addiw	s1,a1,-1
    80006d2c:	a881                	j	80006d7c <bd_free+0xc0>
    if(buddy % 2 == 0) {
      p = q;
    }
    // at size k+1, mark that the merged buddy pair isn't split
    // anymore
    bit_clear(bd_sizes[k+1].split, blk_index(k+1, p));
    80006d2e:	020a8a93          	addi	s5,s5,32
    80006d32:	2905                	addiw	s2,s2,1
  int n = p - (char *) bd_base;
    80006d34:	000cb583          	ld	a1,0(s9)
  return n / BLK_SIZE(k);
    80006d38:	40bb05bb          	subw	a1,s6,a1
    80006d3c:	012c17b3          	sll	a5,s8,s2
    80006d40:	02f5c5b3          	div	a1,a1,a5
    bit_clear(bd_sizes[k+1].split, blk_index(k+1, p));
    80006d44:	000bb783          	ld	a5,0(s7)
    80006d48:	97d6                	add	a5,a5,s5
    80006d4a:	2581                	sext.w	a1,a1
    80006d4c:	6f88                	ld	a0,24(a5)
    80006d4e:	00000097          	auipc	ra,0x0
    80006d52:	b1a080e7          	jalr	-1254(ra) # 80006868 <bit_clear>
  for (k = size(p); k < MAXSIZE; k++) {
    80006d56:	000d2783          	lw	a5,0(s10)
    80006d5a:	37fd                	addiw	a5,a5,-1
    80006d5c:	04f95e63          	ble	a5,s2,80006db8 <bd_free+0xfc>
  int n = p - (char *) bd_base;
    80006d60:	000cb983          	ld	s3,0(s9)
  return n / BLK_SIZE(k);
    80006d64:	012c1a33          	sll	s4,s8,s2
    80006d68:	413b07bb          	subw	a5,s6,s3
    80006d6c:	0347c7b3          	div	a5,a5,s4
    80006d70:	0007859b          	sext.w	a1,a5
    int buddy = (bi % 2 == 0) ? bi+1 : bi-1;
    80006d74:	8b85                	andi	a5,a5,1
    80006d76:	fbcd                	bnez	a5,80006d28 <bd_free+0x6c>
    80006d78:	0015849b          	addiw	s1,a1,1
    bit_clear(bd_sizes[k].alloc, bi);  // free p at size k
    80006d7c:	000bbd83          	ld	s11,0(s7)
    80006d80:	9dd6                	add	s11,s11,s5
    80006d82:	010db503          	ld	a0,16(s11)
    80006d86:	00000097          	auipc	ra,0x0
    80006d8a:	ae2080e7          	jalr	-1310(ra) # 80006868 <bit_clear>
    if (bit_isset(bd_sizes[k].alloc, buddy)) {  // is buddy allocated?
    80006d8e:	85a6                	mv	a1,s1
    80006d90:	010db503          	ld	a0,16(s11)
    80006d94:	00000097          	auipc	ra,0x0
    80006d98:	a6c080e7          	jalr	-1428(ra) # 80006800 <bit_isset>
    80006d9c:	ed11                	bnez	a0,80006db8 <bd_free+0xfc>
  int n = bi * BLK_SIZE(k);
    80006d9e:	2481                	sext.w	s1,s1
  return (char *) bd_base + n;
    80006da0:	029a0a3b          	mulw	s4,s4,s1
    80006da4:	99d2                	add	s3,s3,s4
    lst_remove(q);    // remove buddy from free list
    80006da6:	854e                	mv	a0,s3
    80006da8:	00000097          	auipc	ra,0x0
    80006dac:	64a080e7          	jalr	1610(ra) # 800073f2 <lst_remove>
    if(buddy % 2 == 0) {
    80006db0:	8885                	andi	s1,s1,1
    80006db2:	fcb5                	bnez	s1,80006d2e <bd_free+0x72>
      p = q;
    80006db4:	8b4e                	mv	s6,s3
    80006db6:	bfa5                	j	80006d2e <bd_free+0x72>
  }
  lst_push(&bd_sizes[k].free, p);
    80006db8:	0916                	slli	s2,s2,0x5
    80006dba:	00029797          	auipc	a5,0x29
    80006dbe:	29678793          	addi	a5,a5,662 # 80030050 <bd_sizes>
    80006dc2:	6388                	ld	a0,0(a5)
    80006dc4:	85da                	mv	a1,s6
    80006dc6:	954a                	add	a0,a0,s2
    80006dc8:	00000097          	auipc	ra,0x0
    80006dcc:	676080e7          	jalr	1654(ra) # 8000743e <lst_push>
  release(&lock);
    80006dd0:	00029517          	auipc	a0,0x29
    80006dd4:	23050513          	addi	a0,a0,560 # 80030000 <lock>
    80006dd8:	ffffa097          	auipc	ra,0xffffa
    80006ddc:	ede080e7          	jalr	-290(ra) # 80000cb6 <release>
}
    80006de0:	70a6                	ld	ra,104(sp)
    80006de2:	7406                	ld	s0,96(sp)
    80006de4:	64e6                	ld	s1,88(sp)
    80006de6:	6946                	ld	s2,80(sp)
    80006de8:	69a6                	ld	s3,72(sp)
    80006dea:	6a06                	ld	s4,64(sp)
    80006dec:	7ae2                	ld	s5,56(sp)
    80006dee:	7b42                	ld	s6,48(sp)
    80006df0:	7ba2                	ld	s7,40(sp)
    80006df2:	7c02                	ld	s8,32(sp)
    80006df4:	6ce2                	ld	s9,24(sp)
    80006df6:	6d42                	ld	s10,16(sp)
    80006df8:	6da2                	ld	s11,8(sp)
    80006dfa:	6165                	addi	sp,sp,112
    80006dfc:	8082                	ret

0000000080006dfe <blk_index_next>:

// Compute the first block at size k that doesn't contain p
int
blk_index_next(int k, char *p) {
    80006dfe:	1141                	addi	sp,sp,-16
    80006e00:	e422                	sd	s0,8(sp)
    80006e02:	0800                	addi	s0,sp,16
  int n = (p - (char *) bd_base) / BLK_SIZE(k);
    80006e04:	00029797          	auipc	a5,0x29
    80006e08:	24478793          	addi	a5,a5,580 # 80030048 <bd_base>
    80006e0c:	639c                	ld	a5,0(a5)
    80006e0e:	8d9d                	sub	a1,a1,a5
    80006e10:	47c1                	li	a5,16
    80006e12:	00a797b3          	sll	a5,a5,a0
    80006e16:	02f5c533          	div	a0,a1,a5
    80006e1a:	2501                	sext.w	a0,a0
  if((p - (char*) bd_base) % BLK_SIZE(k) != 0)
    80006e1c:	02f5e5b3          	rem	a1,a1,a5
    80006e20:	c191                	beqz	a1,80006e24 <blk_index_next+0x26>
      n++;
    80006e22:	2505                	addiw	a0,a0,1
  return n ;
}
    80006e24:	6422                	ld	s0,8(sp)
    80006e26:	0141                	addi	sp,sp,16
    80006e28:	8082                	ret

0000000080006e2a <log2>:

int
log2(uint64 n) {
    80006e2a:	1141                	addi	sp,sp,-16
    80006e2c:	e422                	sd	s0,8(sp)
    80006e2e:	0800                	addi	s0,sp,16
  int k = 0;
  while (n > 1) {
    80006e30:	4705                	li	a4,1
    80006e32:	00a77b63          	bleu	a0,a4,80006e48 <log2+0x1e>
    80006e36:	87aa                	mv	a5,a0
  int k = 0;
    80006e38:	4501                	li	a0,0
    k++;
    80006e3a:	2505                	addiw	a0,a0,1
    n = n >> 1;
    80006e3c:	8385                	srli	a5,a5,0x1
  while (n > 1) {
    80006e3e:	fef76ee3          	bltu	a4,a5,80006e3a <log2+0x10>
  }
  return k;
}
    80006e42:	6422                	ld	s0,8(sp)
    80006e44:	0141                	addi	sp,sp,16
    80006e46:	8082                	ret
  int k = 0;
    80006e48:	4501                	li	a0,0
    80006e4a:	bfe5                	j	80006e42 <log2+0x18>

0000000080006e4c <bd_mark>:

// Mark memory from [start, stop), starting at size 0, as allocated. 
void
bd_mark(void *start, void *stop)
{
    80006e4c:	711d                	addi	sp,sp,-96
    80006e4e:	ec86                	sd	ra,88(sp)
    80006e50:	e8a2                	sd	s0,80(sp)
    80006e52:	e4a6                	sd	s1,72(sp)
    80006e54:	e0ca                	sd	s2,64(sp)
    80006e56:	fc4e                	sd	s3,56(sp)
    80006e58:	f852                	sd	s4,48(sp)
    80006e5a:	f456                	sd	s5,40(sp)
    80006e5c:	f05a                	sd	s6,32(sp)
    80006e5e:	ec5e                	sd	s7,24(sp)
    80006e60:	e862                	sd	s8,16(sp)
    80006e62:	e466                	sd	s9,8(sp)
    80006e64:	e06a                	sd	s10,0(sp)
    80006e66:	1080                	addi	s0,sp,96
  int bi, bj;

  if (((uint64) start % LEAF_SIZE != 0) || ((uint64) stop % LEAF_SIZE != 0))
    80006e68:	00b56933          	or	s2,a0,a1
    80006e6c:	00f97913          	andi	s2,s2,15
    80006e70:	04091463          	bnez	s2,80006eb8 <bd_mark+0x6c>
    80006e74:	8baa                	mv	s7,a0
    80006e76:	8c2e                	mv	s8,a1
    panic("bd_mark");

  for (int k = 0; k < nsizes; k++) {
    80006e78:	00029797          	auipc	a5,0x29
    80006e7c:	1e078793          	addi	a5,a5,480 # 80030058 <nsizes>
    80006e80:	0007ab03          	lw	s6,0(a5)
    80006e84:	4981                	li	s3,0
  int n = p - (char *) bd_base;
    80006e86:	00029d17          	auipc	s10,0x29
    80006e8a:	1c2d0d13          	addi	s10,s10,450 # 80030048 <bd_base>
  return n / BLK_SIZE(k);
    80006e8e:	4cc1                	li	s9,16
    bi = blk_index(k, start);
    bj = blk_index_next(k, stop);
    for(; bi < bj; bi++) {
      if(k > 0) {
        // if a block is allocated at size k, mark it as split too.
        bit_set(bd_sizes[k].split, bi);
    80006e90:	00029a17          	auipc	s4,0x29
    80006e94:	1c0a0a13          	addi	s4,s4,448 # 80030050 <bd_sizes>
  for (int k = 0; k < nsizes; k++) {
    80006e98:	07604563          	bgtz	s6,80006f02 <bd_mark+0xb6>
      }
      bit_set(bd_sizes[k].alloc, bi);
    }
  }
}
    80006e9c:	60e6                	ld	ra,88(sp)
    80006e9e:	6446                	ld	s0,80(sp)
    80006ea0:	64a6                	ld	s1,72(sp)
    80006ea2:	6906                	ld	s2,64(sp)
    80006ea4:	79e2                	ld	s3,56(sp)
    80006ea6:	7a42                	ld	s4,48(sp)
    80006ea8:	7aa2                	ld	s5,40(sp)
    80006eaa:	7b02                	ld	s6,32(sp)
    80006eac:	6be2                	ld	s7,24(sp)
    80006eae:	6c42                	ld	s8,16(sp)
    80006eb0:	6ca2                	ld	s9,8(sp)
    80006eb2:	6d02                	ld	s10,0(sp)
    80006eb4:	6125                	addi	sp,sp,96
    80006eb6:	8082                	ret
    panic("bd_mark");
    80006eb8:	00002517          	auipc	a0,0x2
    80006ebc:	b2850513          	addi	a0,a0,-1240 # 800089e0 <userret+0x950>
    80006ec0:	ffff9097          	auipc	ra,0xffff9
    80006ec4:	6be080e7          	jalr	1726(ra) # 8000057e <panic>
      bit_set(bd_sizes[k].alloc, bi);
    80006ec8:	000a3783          	ld	a5,0(s4)
    80006ecc:	97ca                	add	a5,a5,s2
    80006ece:	85a6                	mv	a1,s1
    80006ed0:	6b88                	ld	a0,16(a5)
    80006ed2:	00000097          	auipc	ra,0x0
    80006ed6:	966080e7          	jalr	-1690(ra) # 80006838 <bit_set>
    for(; bi < bj; bi++) {
    80006eda:	2485                	addiw	s1,s1,1
    80006edc:	009a8e63          	beq	s5,s1,80006ef8 <bd_mark+0xac>
      if(k > 0) {
    80006ee0:	ff3054e3          	blez	s3,80006ec8 <bd_mark+0x7c>
        bit_set(bd_sizes[k].split, bi);
    80006ee4:	000a3783          	ld	a5,0(s4)
    80006ee8:	97ca                	add	a5,a5,s2
    80006eea:	85a6                	mv	a1,s1
    80006eec:	6f88                	ld	a0,24(a5)
    80006eee:	00000097          	auipc	ra,0x0
    80006ef2:	94a080e7          	jalr	-1718(ra) # 80006838 <bit_set>
    80006ef6:	bfc9                	j	80006ec8 <bd_mark+0x7c>
  for (int k = 0; k < nsizes; k++) {
    80006ef8:	2985                	addiw	s3,s3,1
    80006efa:	02090913          	addi	s2,s2,32
    80006efe:	f9698fe3          	beq	s3,s6,80006e9c <bd_mark+0x50>
  int n = p - (char *) bd_base;
    80006f02:	000d3483          	ld	s1,0(s10)
  return n / BLK_SIZE(k);
    80006f06:	409b84bb          	subw	s1,s7,s1
    80006f0a:	013c97b3          	sll	a5,s9,s3
    80006f0e:	02f4c4b3          	div	s1,s1,a5
    80006f12:	2481                	sext.w	s1,s1
    bj = blk_index_next(k, stop);
    80006f14:	85e2                	mv	a1,s8
    80006f16:	854e                	mv	a0,s3
    80006f18:	00000097          	auipc	ra,0x0
    80006f1c:	ee6080e7          	jalr	-282(ra) # 80006dfe <blk_index_next>
    80006f20:	8aaa                	mv	s5,a0
    for(; bi < bj; bi++) {
    80006f22:	faa4cfe3          	blt	s1,a0,80006ee0 <bd_mark+0x94>
    80006f26:	bfc9                	j	80006ef8 <bd_mark+0xac>

0000000080006f28 <bd_initfree_pair>:

// If a block is marked as allocated and the buddy is free, put the
// buddy on the free list at size k.
int
bd_initfree_pair(int k, int bi) {
    80006f28:	7139                	addi	sp,sp,-64
    80006f2a:	fc06                	sd	ra,56(sp)
    80006f2c:	f822                	sd	s0,48(sp)
    80006f2e:	f426                	sd	s1,40(sp)
    80006f30:	f04a                	sd	s2,32(sp)
    80006f32:	ec4e                	sd	s3,24(sp)
    80006f34:	e852                	sd	s4,16(sp)
    80006f36:	e456                	sd	s5,8(sp)
    80006f38:	e05a                	sd	s6,0(sp)
    80006f3a:	0080                	addi	s0,sp,64
    80006f3c:	8b2a                	mv	s6,a0
  int buddy = (bi % 2 == 0) ? bi+1 : bi-1;
    80006f3e:	00058a1b          	sext.w	s4,a1
    80006f42:	001a7793          	andi	a5,s4,1
    80006f46:	ebbd                	bnez	a5,80006fbc <bd_initfree_pair+0x94>
    80006f48:	00158a9b          	addiw	s5,a1,1
  int free = 0;
  if(bit_isset(bd_sizes[k].alloc, bi) !=  bit_isset(bd_sizes[k].alloc, buddy)) {
    80006f4c:	005b1493          	slli	s1,s6,0x5
    80006f50:	00029797          	auipc	a5,0x29
    80006f54:	10078793          	addi	a5,a5,256 # 80030050 <bd_sizes>
    80006f58:	639c                	ld	a5,0(a5)
    80006f5a:	94be                	add	s1,s1,a5
    80006f5c:	0104b903          	ld	s2,16(s1)
    80006f60:	854a                	mv	a0,s2
    80006f62:	00000097          	auipc	ra,0x0
    80006f66:	89e080e7          	jalr	-1890(ra) # 80006800 <bit_isset>
    80006f6a:	89aa                	mv	s3,a0
    80006f6c:	85d6                	mv	a1,s5
    80006f6e:	854a                	mv	a0,s2
    80006f70:	00000097          	auipc	ra,0x0
    80006f74:	890080e7          	jalr	-1904(ra) # 80006800 <bit_isset>
  int free = 0;
    80006f78:	4901                	li	s2,0
  if(bit_isset(bd_sizes[k].alloc, bi) !=  bit_isset(bd_sizes[k].alloc, buddy)) {
    80006f7a:	02a98663          	beq	s3,a0,80006fa6 <bd_initfree_pair+0x7e>
    // one of the pair is free
    free = BLK_SIZE(k);
    80006f7e:	45c1                	li	a1,16
    80006f80:	016595b3          	sll	a1,a1,s6
    80006f84:	0005891b          	sext.w	s2,a1
    if(bit_isset(bd_sizes[k].alloc, bi))
    80006f88:	02098d63          	beqz	s3,80006fc2 <bd_initfree_pair+0x9a>
  return (char *) bd_base + n;
    80006f8c:	035585bb          	mulw	a1,a1,s5
    80006f90:	00029797          	auipc	a5,0x29
    80006f94:	0b878793          	addi	a5,a5,184 # 80030048 <bd_base>
    80006f98:	639c                	ld	a5,0(a5)
      lst_push(&bd_sizes[k].free, addr(k, buddy));   // put buddy on free list
    80006f9a:	95be                	add	a1,a1,a5
    80006f9c:	8526                	mv	a0,s1
    80006f9e:	00000097          	auipc	ra,0x0
    80006fa2:	4a0080e7          	jalr	1184(ra) # 8000743e <lst_push>
    else
      lst_push(&bd_sizes[k].free, addr(k, bi));      // put bi on free list
  }
  return free;
}
    80006fa6:	854a                	mv	a0,s2
    80006fa8:	70e2                	ld	ra,56(sp)
    80006faa:	7442                	ld	s0,48(sp)
    80006fac:	74a2                	ld	s1,40(sp)
    80006fae:	7902                	ld	s2,32(sp)
    80006fb0:	69e2                	ld	s3,24(sp)
    80006fb2:	6a42                	ld	s4,16(sp)
    80006fb4:	6aa2                	ld	s5,8(sp)
    80006fb6:	6b02                	ld	s6,0(sp)
    80006fb8:	6121                	addi	sp,sp,64
    80006fba:	8082                	ret
  int buddy = (bi % 2 == 0) ? bi+1 : bi-1;
    80006fbc:	fff58a9b          	addiw	s5,a1,-1
    80006fc0:	b771                	j	80006f4c <bd_initfree_pair+0x24>
  return (char *) bd_base + n;
    80006fc2:	034585bb          	mulw	a1,a1,s4
    80006fc6:	00029797          	auipc	a5,0x29
    80006fca:	08278793          	addi	a5,a5,130 # 80030048 <bd_base>
    80006fce:	639c                	ld	a5,0(a5)
      lst_push(&bd_sizes[k].free, addr(k, bi));      // put bi on free list
    80006fd0:	95be                	add	a1,a1,a5
    80006fd2:	8526                	mv	a0,s1
    80006fd4:	00000097          	auipc	ra,0x0
    80006fd8:	46a080e7          	jalr	1130(ra) # 8000743e <lst_push>
    80006fdc:	b7e9                	j	80006fa6 <bd_initfree_pair+0x7e>

0000000080006fde <bd_initfree>:
  
// Initialize the free lists for each size k.  For each size k, there
// are only two pairs that may have a buddy that should be on free list:
// bd_left and bd_right.
int
bd_initfree(void *bd_left, void *bd_right) {
    80006fde:	711d                	addi	sp,sp,-96
    80006fe0:	ec86                	sd	ra,88(sp)
    80006fe2:	e8a2                	sd	s0,80(sp)
    80006fe4:	e4a6                	sd	s1,72(sp)
    80006fe6:	e0ca                	sd	s2,64(sp)
    80006fe8:	fc4e                	sd	s3,56(sp)
    80006fea:	f852                	sd	s4,48(sp)
    80006fec:	f456                	sd	s5,40(sp)
    80006fee:	f05a                	sd	s6,32(sp)
    80006ff0:	ec5e                	sd	s7,24(sp)
    80006ff2:	e862                	sd	s8,16(sp)
    80006ff4:	e466                	sd	s9,8(sp)
    80006ff6:	e06a                	sd	s10,0(sp)
    80006ff8:	1080                	addi	s0,sp,96
  int free = 0;

  for (int k = 0; k < MAXSIZE; k++) {   // skip max size
    80006ffa:	00029797          	auipc	a5,0x29
    80006ffe:	05e78793          	addi	a5,a5,94 # 80030058 <nsizes>
    80007002:	4398                	lw	a4,0(a5)
    80007004:	4785                	li	a5,1
    80007006:	06e7db63          	ble	a4,a5,8000707c <bd_initfree+0x9e>
    8000700a:	8b2e                	mv	s6,a1
    8000700c:	8aaa                	mv	s5,a0
    8000700e:	4901                	li	s2,0
  int free = 0;
    80007010:	4a01                	li	s4,0
  int n = p - (char *) bd_base;
    80007012:	00029c97          	auipc	s9,0x29
    80007016:	036c8c93          	addi	s9,s9,54 # 80030048 <bd_base>
  return n / BLK_SIZE(k);
    8000701a:	4c41                	li	s8,16
  for (int k = 0; k < MAXSIZE; k++) {   // skip max size
    8000701c:	00029b97          	auipc	s7,0x29
    80007020:	03cb8b93          	addi	s7,s7,60 # 80030058 <nsizes>
    80007024:	a039                	j	80007032 <bd_initfree+0x54>
    80007026:	2905                	addiw	s2,s2,1
    80007028:	000ba783          	lw	a5,0(s7)
    8000702c:	37fd                	addiw	a5,a5,-1
    8000702e:	04f95863          	ble	a5,s2,8000707e <bd_initfree+0xa0>
    int left = blk_index_next(k, bd_left);
    80007032:	85d6                	mv	a1,s5
    80007034:	854a                	mv	a0,s2
    80007036:	00000097          	auipc	ra,0x0
    8000703a:	dc8080e7          	jalr	-568(ra) # 80006dfe <blk_index_next>
    8000703e:	89aa                	mv	s3,a0
  int n = p - (char *) bd_base;
    80007040:	000cb483          	ld	s1,0(s9)
  return n / BLK_SIZE(k);
    80007044:	409b04bb          	subw	s1,s6,s1
    80007048:	012c17b3          	sll	a5,s8,s2
    8000704c:	02f4c4b3          	div	s1,s1,a5
    80007050:	2481                	sext.w	s1,s1
    int right = blk_index(k, bd_right);
    free += bd_initfree_pair(k, left);
    80007052:	85aa                	mv	a1,a0
    80007054:	854a                	mv	a0,s2
    80007056:	00000097          	auipc	ra,0x0
    8000705a:	ed2080e7          	jalr	-302(ra) # 80006f28 <bd_initfree_pair>
    8000705e:	01450d3b          	addw	s10,a0,s4
    80007062:	000d0a1b          	sext.w	s4,s10
    if(right <= left)
    80007066:	fc99d0e3          	ble	s1,s3,80007026 <bd_initfree+0x48>
      continue;
    free += bd_initfree_pair(k, right);
    8000706a:	85a6                	mv	a1,s1
    8000706c:	854a                	mv	a0,s2
    8000706e:	00000097          	auipc	ra,0x0
    80007072:	eba080e7          	jalr	-326(ra) # 80006f28 <bd_initfree_pair>
    80007076:	00ad0a3b          	addw	s4,s10,a0
    8000707a:	b775                	j	80007026 <bd_initfree+0x48>
  int free = 0;
    8000707c:	4a01                	li	s4,0
  }
  return free;
}
    8000707e:	8552                	mv	a0,s4
    80007080:	60e6                	ld	ra,88(sp)
    80007082:	6446                	ld	s0,80(sp)
    80007084:	64a6                	ld	s1,72(sp)
    80007086:	6906                	ld	s2,64(sp)
    80007088:	79e2                	ld	s3,56(sp)
    8000708a:	7a42                	ld	s4,48(sp)
    8000708c:	7aa2                	ld	s5,40(sp)
    8000708e:	7b02                	ld	s6,32(sp)
    80007090:	6be2                	ld	s7,24(sp)
    80007092:	6c42                	ld	s8,16(sp)
    80007094:	6ca2                	ld	s9,8(sp)
    80007096:	6d02                	ld	s10,0(sp)
    80007098:	6125                	addi	sp,sp,96
    8000709a:	8082                	ret

000000008000709c <bd_mark_data_structures>:

// Mark the range [bd_base,p) as allocated
int
bd_mark_data_structures(char *p) {
    8000709c:	7179                	addi	sp,sp,-48
    8000709e:	f406                	sd	ra,40(sp)
    800070a0:	f022                	sd	s0,32(sp)
    800070a2:	ec26                	sd	s1,24(sp)
    800070a4:	e84a                	sd	s2,16(sp)
    800070a6:	e44e                	sd	s3,8(sp)
    800070a8:	1800                	addi	s0,sp,48
    800070aa:	89aa                	mv	s3,a0
  int meta = p - (char*)bd_base;
    800070ac:	00029917          	auipc	s2,0x29
    800070b0:	f9c90913          	addi	s2,s2,-100 # 80030048 <bd_base>
    800070b4:	00093483          	ld	s1,0(s2)
    800070b8:	409504bb          	subw	s1,a0,s1
  printf("bd: %d meta bytes for managing %d bytes of memory\n", meta, BLK_SIZE(MAXSIZE));
    800070bc:	00029797          	auipc	a5,0x29
    800070c0:	f9c78793          	addi	a5,a5,-100 # 80030058 <nsizes>
    800070c4:	439c                	lw	a5,0(a5)
    800070c6:	37fd                	addiw	a5,a5,-1
    800070c8:	4641                	li	a2,16
    800070ca:	00f61633          	sll	a2,a2,a5
    800070ce:	85a6                	mv	a1,s1
    800070d0:	00002517          	auipc	a0,0x2
    800070d4:	91850513          	addi	a0,a0,-1768 # 800089e8 <userret+0x958>
    800070d8:	ffff9097          	auipc	ra,0xffff9
    800070dc:	500080e7          	jalr	1280(ra) # 800005d8 <printf>
  bd_mark(bd_base, p);
    800070e0:	85ce                	mv	a1,s3
    800070e2:	00093503          	ld	a0,0(s2)
    800070e6:	00000097          	auipc	ra,0x0
    800070ea:	d66080e7          	jalr	-666(ra) # 80006e4c <bd_mark>
  return meta;
}
    800070ee:	8526                	mv	a0,s1
    800070f0:	70a2                	ld	ra,40(sp)
    800070f2:	7402                	ld	s0,32(sp)
    800070f4:	64e2                	ld	s1,24(sp)
    800070f6:	6942                	ld	s2,16(sp)
    800070f8:	69a2                	ld	s3,8(sp)
    800070fa:	6145                	addi	sp,sp,48
    800070fc:	8082                	ret

00000000800070fe <bd_mark_unavailable>:

// Mark the range [end, HEAPSIZE) as allocated
int
bd_mark_unavailable(void *end, void *left) {
    800070fe:	1101                	addi	sp,sp,-32
    80007100:	ec06                	sd	ra,24(sp)
    80007102:	e822                	sd	s0,16(sp)
    80007104:	e426                	sd	s1,8(sp)
    80007106:	1000                	addi	s0,sp,32
  int unavailable = BLK_SIZE(MAXSIZE)-(end-bd_base);
    80007108:	00029797          	auipc	a5,0x29
    8000710c:	f5078793          	addi	a5,a5,-176 # 80030058 <nsizes>
    80007110:	4384                	lw	s1,0(a5)
    80007112:	fff4879b          	addiw	a5,s1,-1
    80007116:	44c1                	li	s1,16
    80007118:	00f494b3          	sll	s1,s1,a5
    8000711c:	00029797          	auipc	a5,0x29
    80007120:	f2c78793          	addi	a5,a5,-212 # 80030048 <bd_base>
    80007124:	639c                	ld	a5,0(a5)
    80007126:	8d1d                	sub	a0,a0,a5
    80007128:	40a4853b          	subw	a0,s1,a0
    8000712c:	0005049b          	sext.w	s1,a0
  if(unavailable > 0)
    80007130:	00905a63          	blez	s1,80007144 <bd_mark_unavailable+0x46>
    unavailable = ROUNDUP(unavailable, LEAF_SIZE);
    80007134:	357d                	addiw	a0,a0,-1
    80007136:	41f5549b          	sraiw	s1,a0,0x1f
    8000713a:	01c4d49b          	srliw	s1,s1,0x1c
    8000713e:	9ca9                	addw	s1,s1,a0
    80007140:	98c1                	andi	s1,s1,-16
    80007142:	24c1                	addiw	s1,s1,16
  printf("bd: 0x%x bytes unavailable\n", unavailable);
    80007144:	85a6                	mv	a1,s1
    80007146:	00002517          	auipc	a0,0x2
    8000714a:	8da50513          	addi	a0,a0,-1830 # 80008a20 <userret+0x990>
    8000714e:	ffff9097          	auipc	ra,0xffff9
    80007152:	48a080e7          	jalr	1162(ra) # 800005d8 <printf>

  void *bd_end = bd_base+BLK_SIZE(MAXSIZE)-unavailable;
    80007156:	00029797          	auipc	a5,0x29
    8000715a:	ef278793          	addi	a5,a5,-270 # 80030048 <bd_base>
    8000715e:	6398                	ld	a4,0(a5)
    80007160:	00029797          	auipc	a5,0x29
    80007164:	ef878793          	addi	a5,a5,-264 # 80030058 <nsizes>
    80007168:	438c                	lw	a1,0(a5)
    8000716a:	fff5879b          	addiw	a5,a1,-1
    8000716e:	45c1                	li	a1,16
    80007170:	00f595b3          	sll	a1,a1,a5
    80007174:	40958533          	sub	a0,a1,s1
  bd_mark(bd_end, bd_base+BLK_SIZE(MAXSIZE));
    80007178:	95ba                	add	a1,a1,a4
    8000717a:	953a                	add	a0,a0,a4
    8000717c:	00000097          	auipc	ra,0x0
    80007180:	cd0080e7          	jalr	-816(ra) # 80006e4c <bd_mark>
  return unavailable;
}
    80007184:	8526                	mv	a0,s1
    80007186:	60e2                	ld	ra,24(sp)
    80007188:	6442                	ld	s0,16(sp)
    8000718a:	64a2                	ld	s1,8(sp)
    8000718c:	6105                	addi	sp,sp,32
    8000718e:	8082                	ret

0000000080007190 <bd_init>:

// Initialize the buddy allocator: it manages memory from [base, end).
void
bd_init(void *base, void *end) {
    80007190:	715d                	addi	sp,sp,-80
    80007192:	e486                	sd	ra,72(sp)
    80007194:	e0a2                	sd	s0,64(sp)
    80007196:	fc26                	sd	s1,56(sp)
    80007198:	f84a                	sd	s2,48(sp)
    8000719a:	f44e                	sd	s3,40(sp)
    8000719c:	f052                	sd	s4,32(sp)
    8000719e:	ec56                	sd	s5,24(sp)
    800071a0:	e85a                	sd	s6,16(sp)
    800071a2:	e45e                	sd	s7,8(sp)
    800071a4:	e062                	sd	s8,0(sp)
    800071a6:	0880                	addi	s0,sp,80
    800071a8:	8c2e                	mv	s8,a1
  char *p = (char *) ROUNDUP((uint64)base, LEAF_SIZE);
    800071aa:	fff50493          	addi	s1,a0,-1
    800071ae:	98c1                	andi	s1,s1,-16
    800071b0:	04c1                	addi	s1,s1,16
  int sz;

  initlock(&lock, "buddy");
    800071b2:	00002597          	auipc	a1,0x2
    800071b6:	88e58593          	addi	a1,a1,-1906 # 80008a40 <userret+0x9b0>
    800071ba:	00029517          	auipc	a0,0x29
    800071be:	e4650513          	addi	a0,a0,-442 # 80030000 <lock>
    800071c2:	ffffa097          	auipc	ra,0xffffa
    800071c6:	934080e7          	jalr	-1740(ra) # 80000af6 <initlock>
  bd_base = (void *) p;
    800071ca:	00029797          	auipc	a5,0x29
    800071ce:	e697bf23          	sd	s1,-386(a5) # 80030048 <bd_base>

  // compute the number of sizes we need to manage [base, end)
  nsizes = log2(((char *)end-p)/LEAF_SIZE) + 1;
    800071d2:	409c0933          	sub	s2,s8,s1
    800071d6:	43f95513          	srai	a0,s2,0x3f
    800071da:	893d                	andi	a0,a0,15
    800071dc:	954a                	add	a0,a0,s2
    800071de:	8511                	srai	a0,a0,0x4
    800071e0:	00000097          	auipc	ra,0x0
    800071e4:	c4a080e7          	jalr	-950(ra) # 80006e2a <log2>
  if((char*)end-p > BLK_SIZE(MAXSIZE)) {
    800071e8:	47c1                	li	a5,16
    800071ea:	00a797b3          	sll	a5,a5,a0
    800071ee:	1b27c863          	blt	a5,s2,8000739e <bd_init+0x20e>
  nsizes = log2(((char *)end-p)/LEAF_SIZE) + 1;
    800071f2:	2505                	addiw	a0,a0,1
    800071f4:	00029797          	auipc	a5,0x29
    800071f8:	e6a7a223          	sw	a0,-412(a5) # 80030058 <nsizes>
    nsizes++;  // round up to the next power of 2
  }

  printf("bd: memory sz is %d bytes; allocate an size array of length %d\n",
    800071fc:	00029997          	auipc	s3,0x29
    80007200:	e5c98993          	addi	s3,s3,-420 # 80030058 <nsizes>
    80007204:	0009a603          	lw	a2,0(s3)
    80007208:	85ca                	mv	a1,s2
    8000720a:	00002517          	auipc	a0,0x2
    8000720e:	83e50513          	addi	a0,a0,-1986 # 80008a48 <userret+0x9b8>
    80007212:	ffff9097          	auipc	ra,0xffff9
    80007216:	3c6080e7          	jalr	966(ra) # 800005d8 <printf>
         (char*) end - p, nsizes);

  // allocate bd_sizes array
  bd_sizes = (Sz_info *) p;
    8000721a:	00029797          	auipc	a5,0x29
    8000721e:	e297bb23          	sd	s1,-458(a5) # 80030050 <bd_sizes>
  p += sizeof(Sz_info) * nsizes;
    80007222:	0009a603          	lw	a2,0(s3)
    80007226:	00561913          	slli	s2,a2,0x5
    8000722a:	9926                	add	s2,s2,s1
  memset(bd_sizes, 0, sizeof(Sz_info) * nsizes);
    8000722c:	0056161b          	slliw	a2,a2,0x5
    80007230:	4581                	li	a1,0
    80007232:	8526                	mv	a0,s1
    80007234:	ffffa097          	auipc	ra,0xffffa
    80007238:	ca8080e7          	jalr	-856(ra) # 80000edc <memset>

  // initialize free list and allocate the alloc array for each size k
  for (int k = 0; k < nsizes; k++) {
    8000723c:	0009a783          	lw	a5,0(s3)
    80007240:	06f05a63          	blez	a5,800072b4 <bd_init+0x124>
    80007244:	4981                	li	s3,0
    lst_init(&bd_sizes[k].free);
    80007246:	00029a97          	auipc	s5,0x29
    8000724a:	e0aa8a93          	addi	s5,s5,-502 # 80030050 <bd_sizes>
    sz = sizeof(char)* ROUNDUP(NBLK(k), 8)/8;
    8000724e:	00029a17          	auipc	s4,0x29
    80007252:	e0aa0a13          	addi	s4,s4,-502 # 80030058 <nsizes>
    80007256:	4b05                	li	s6,1
    lst_init(&bd_sizes[k].free);
    80007258:	00599b93          	slli	s7,s3,0x5
    8000725c:	000ab503          	ld	a0,0(s5)
    80007260:	955e                	add	a0,a0,s7
    80007262:	00000097          	auipc	ra,0x0
    80007266:	16a080e7          	jalr	362(ra) # 800073cc <lst_init>
    sz = sizeof(char)* ROUNDUP(NBLK(k), 8)/8;
    8000726a:	000a2483          	lw	s1,0(s4)
    8000726e:	34fd                	addiw	s1,s1,-1
    80007270:	413484bb          	subw	s1,s1,s3
    80007274:	009b14bb          	sllw	s1,s6,s1
    80007278:	fff4879b          	addiw	a5,s1,-1
    8000727c:	41f7d49b          	sraiw	s1,a5,0x1f
    80007280:	01d4d49b          	srliw	s1,s1,0x1d
    80007284:	9cbd                	addw	s1,s1,a5
    80007286:	98e1                	andi	s1,s1,-8
    80007288:	24a1                	addiw	s1,s1,8
    bd_sizes[k].alloc = p;
    8000728a:	000ab783          	ld	a5,0(s5)
    8000728e:	9bbe                	add	s7,s7,a5
    80007290:	012bb823          	sd	s2,16(s7)
    memset(bd_sizes[k].alloc, 0, sz);
    80007294:	848d                	srai	s1,s1,0x3
    80007296:	8626                	mv	a2,s1
    80007298:	4581                	li	a1,0
    8000729a:	854a                	mv	a0,s2
    8000729c:	ffffa097          	auipc	ra,0xffffa
    800072a0:	c40080e7          	jalr	-960(ra) # 80000edc <memset>
    p += sz;
    800072a4:	9926                	add	s2,s2,s1
  for (int k = 0; k < nsizes; k++) {
    800072a6:	0985                	addi	s3,s3,1
    800072a8:	000a2703          	lw	a4,0(s4)
    800072ac:	0009879b          	sext.w	a5,s3
    800072b0:	fae7c4e3          	blt	a5,a4,80007258 <bd_init+0xc8>
  }

  // allocate the split array for each size k, except for k = 0, since
  // we will not split blocks of size k = 0, the smallest size.
  for (int k = 1; k < nsizes; k++) {
    800072b4:	00029797          	auipc	a5,0x29
    800072b8:	da478793          	addi	a5,a5,-604 # 80030058 <nsizes>
    800072bc:	439c                	lw	a5,0(a5)
    800072be:	4705                	li	a4,1
    800072c0:	06f75163          	ble	a5,a4,80007322 <bd_init+0x192>
    800072c4:	02000a13          	li	s4,32
    800072c8:	4985                	li	s3,1
    sz = sizeof(char)* (ROUNDUP(NBLK(k), 8))/8;
    800072ca:	4b85                	li	s7,1
    bd_sizes[k].split = p;
    800072cc:	00029b17          	auipc	s6,0x29
    800072d0:	d84b0b13          	addi	s6,s6,-636 # 80030050 <bd_sizes>
  for (int k = 1; k < nsizes; k++) {
    800072d4:	00029a97          	auipc	s5,0x29
    800072d8:	d84a8a93          	addi	s5,s5,-636 # 80030058 <nsizes>
    sz = sizeof(char)* (ROUNDUP(NBLK(k), 8))/8;
    800072dc:	37fd                	addiw	a5,a5,-1
    800072de:	413787bb          	subw	a5,a5,s3
    800072e2:	00fb94bb          	sllw	s1,s7,a5
    800072e6:	fff4879b          	addiw	a5,s1,-1
    800072ea:	41f7d49b          	sraiw	s1,a5,0x1f
    800072ee:	01d4d49b          	srliw	s1,s1,0x1d
    800072f2:	9cbd                	addw	s1,s1,a5
    800072f4:	98e1                	andi	s1,s1,-8
    800072f6:	24a1                	addiw	s1,s1,8
    bd_sizes[k].split = p;
    800072f8:	000b3783          	ld	a5,0(s6)
    800072fc:	97d2                	add	a5,a5,s4
    800072fe:	0127bc23          	sd	s2,24(a5)
    memset(bd_sizes[k].split, 0, sz);
    80007302:	848d                	srai	s1,s1,0x3
    80007304:	8626                	mv	a2,s1
    80007306:	4581                	li	a1,0
    80007308:	854a                	mv	a0,s2
    8000730a:	ffffa097          	auipc	ra,0xffffa
    8000730e:	bd2080e7          	jalr	-1070(ra) # 80000edc <memset>
    p += sz;
    80007312:	9926                	add	s2,s2,s1
  for (int k = 1; k < nsizes; k++) {
    80007314:	2985                	addiw	s3,s3,1
    80007316:	000aa783          	lw	a5,0(s5)
    8000731a:	020a0a13          	addi	s4,s4,32
    8000731e:	faf9cfe3          	blt	s3,a5,800072dc <bd_init+0x14c>
  }
  p = (char *) ROUNDUP((uint64) p, LEAF_SIZE);
    80007322:	197d                	addi	s2,s2,-1
    80007324:	ff097913          	andi	s2,s2,-16
    80007328:	0941                	addi	s2,s2,16

  // done allocating; mark the memory range [base, p) as allocated, so
  // that buddy will not hand out that memory.
  int meta = bd_mark_data_structures(p);
    8000732a:	854a                	mv	a0,s2
    8000732c:	00000097          	auipc	ra,0x0
    80007330:	d70080e7          	jalr	-656(ra) # 8000709c <bd_mark_data_structures>
    80007334:	8a2a                	mv	s4,a0
  
  // mark the unavailable memory range [end, HEAP_SIZE) as allocated,
  // so that buddy will not hand out that memory.
  int unavailable = bd_mark_unavailable(end, p);
    80007336:	85ca                	mv	a1,s2
    80007338:	8562                	mv	a0,s8
    8000733a:	00000097          	auipc	ra,0x0
    8000733e:	dc4080e7          	jalr	-572(ra) # 800070fe <bd_mark_unavailable>
    80007342:	89aa                	mv	s3,a0
  void *bd_end = bd_base+BLK_SIZE(MAXSIZE)-unavailable;
    80007344:	00029a97          	auipc	s5,0x29
    80007348:	d14a8a93          	addi	s5,s5,-748 # 80030058 <nsizes>
    8000734c:	000aa783          	lw	a5,0(s5)
    80007350:	37fd                	addiw	a5,a5,-1
    80007352:	44c1                	li	s1,16
    80007354:	00f497b3          	sll	a5,s1,a5
    80007358:	8f89                	sub	a5,a5,a0
    8000735a:	00029717          	auipc	a4,0x29
    8000735e:	cee70713          	addi	a4,a4,-786 # 80030048 <bd_base>
    80007362:	630c                	ld	a1,0(a4)
  
  // initialize free lists for each size k
  int free = bd_initfree(p, bd_end);
    80007364:	95be                	add	a1,a1,a5
    80007366:	854a                	mv	a0,s2
    80007368:	00000097          	auipc	ra,0x0
    8000736c:	c76080e7          	jalr	-906(ra) # 80006fde <bd_initfree>

  // check if the amount that is free is what we expect
  if(free != BLK_SIZE(MAXSIZE)-meta-unavailable) {
    80007370:	000aa603          	lw	a2,0(s5)
    80007374:	367d                	addiw	a2,a2,-1
    80007376:	00c49633          	sll	a2,s1,a2
    8000737a:	41460633          	sub	a2,a2,s4
    8000737e:	41360633          	sub	a2,a2,s3
    80007382:	02c51463          	bne	a0,a2,800073aa <bd_init+0x21a>
    printf("free %d %d\n", free, BLK_SIZE(MAXSIZE)-meta-unavailable);
    panic("bd_init: free mem");
  }
}
    80007386:	60a6                	ld	ra,72(sp)
    80007388:	6406                	ld	s0,64(sp)
    8000738a:	74e2                	ld	s1,56(sp)
    8000738c:	7942                	ld	s2,48(sp)
    8000738e:	79a2                	ld	s3,40(sp)
    80007390:	7a02                	ld	s4,32(sp)
    80007392:	6ae2                	ld	s5,24(sp)
    80007394:	6b42                	ld	s6,16(sp)
    80007396:	6ba2                	ld	s7,8(sp)
    80007398:	6c02                	ld	s8,0(sp)
    8000739a:	6161                	addi	sp,sp,80
    8000739c:	8082                	ret
    nsizes++;  // round up to the next power of 2
    8000739e:	2509                	addiw	a0,a0,2
    800073a0:	00029797          	auipc	a5,0x29
    800073a4:	caa7ac23          	sw	a0,-840(a5) # 80030058 <nsizes>
    800073a8:	bd91                	j	800071fc <bd_init+0x6c>
    printf("free %d %d\n", free, BLK_SIZE(MAXSIZE)-meta-unavailable);
    800073aa:	85aa                	mv	a1,a0
    800073ac:	00001517          	auipc	a0,0x1
    800073b0:	6dc50513          	addi	a0,a0,1756 # 80008a88 <userret+0x9f8>
    800073b4:	ffff9097          	auipc	ra,0xffff9
    800073b8:	224080e7          	jalr	548(ra) # 800005d8 <printf>
    panic("bd_init: free mem");
    800073bc:	00001517          	auipc	a0,0x1
    800073c0:	6dc50513          	addi	a0,a0,1756 # 80008a98 <userret+0xa08>
    800073c4:	ffff9097          	auipc	ra,0xffff9
    800073c8:	1ba080e7          	jalr	442(ra) # 8000057e <panic>

00000000800073cc <lst_init>:
// fast. circular simplifies code, because don't have to check for
// empty list in insert and remove.

void
lst_init(struct list *lst)
{
    800073cc:	1141                	addi	sp,sp,-16
    800073ce:	e422                	sd	s0,8(sp)
    800073d0:	0800                	addi	s0,sp,16
  lst->next = lst;
    800073d2:	e108                	sd	a0,0(a0)
  lst->prev = lst;
    800073d4:	e508                	sd	a0,8(a0)
}
    800073d6:	6422                	ld	s0,8(sp)
    800073d8:	0141                	addi	sp,sp,16
    800073da:	8082                	ret

00000000800073dc <lst_empty>:

int
lst_empty(struct list *lst) {
    800073dc:	1141                	addi	sp,sp,-16
    800073de:	e422                	sd	s0,8(sp)
    800073e0:	0800                	addi	s0,sp,16
  return lst->next == lst;
    800073e2:	611c                	ld	a5,0(a0)
    800073e4:	40a78533          	sub	a0,a5,a0
}
    800073e8:	00153513          	seqz	a0,a0
    800073ec:	6422                	ld	s0,8(sp)
    800073ee:	0141                	addi	sp,sp,16
    800073f0:	8082                	ret

00000000800073f2 <lst_remove>:

void
lst_remove(struct list *e) {
    800073f2:	1141                	addi	sp,sp,-16
    800073f4:	e422                	sd	s0,8(sp)
    800073f6:	0800                	addi	s0,sp,16
  e->prev->next = e->next;
    800073f8:	6518                	ld	a4,8(a0)
    800073fa:	611c                	ld	a5,0(a0)
    800073fc:	e31c                	sd	a5,0(a4)
  e->next->prev = e->prev;
    800073fe:	6518                	ld	a4,8(a0)
    80007400:	e798                	sd	a4,8(a5)
}
    80007402:	6422                	ld	s0,8(sp)
    80007404:	0141                	addi	sp,sp,16
    80007406:	8082                	ret

0000000080007408 <lst_pop>:

void*
lst_pop(struct list *lst) {
    80007408:	1101                	addi	sp,sp,-32
    8000740a:	ec06                	sd	ra,24(sp)
    8000740c:	e822                	sd	s0,16(sp)
    8000740e:	e426                	sd	s1,8(sp)
    80007410:	1000                	addi	s0,sp,32
  if(lst->next == lst)
    80007412:	6104                	ld	s1,0(a0)
    80007414:	00a48d63          	beq	s1,a0,8000742e <lst_pop+0x26>
    panic("lst_pop");
  struct list *p = lst->next;
  lst_remove(p);
    80007418:	8526                	mv	a0,s1
    8000741a:	00000097          	auipc	ra,0x0
    8000741e:	fd8080e7          	jalr	-40(ra) # 800073f2 <lst_remove>
  return (void *)p;
}
    80007422:	8526                	mv	a0,s1
    80007424:	60e2                	ld	ra,24(sp)
    80007426:	6442                	ld	s0,16(sp)
    80007428:	64a2                	ld	s1,8(sp)
    8000742a:	6105                	addi	sp,sp,32
    8000742c:	8082                	ret
    panic("lst_pop");
    8000742e:	00001517          	auipc	a0,0x1
    80007432:	68250513          	addi	a0,a0,1666 # 80008ab0 <userret+0xa20>
    80007436:	ffff9097          	auipc	ra,0xffff9
    8000743a:	148080e7          	jalr	328(ra) # 8000057e <panic>

000000008000743e <lst_push>:

void
lst_push(struct list *lst, void *p)
{
    8000743e:	1141                	addi	sp,sp,-16
    80007440:	e422                	sd	s0,8(sp)
    80007442:	0800                	addi	s0,sp,16
  struct list *e = (struct list *) p;
  e->next = lst->next;
    80007444:	611c                	ld	a5,0(a0)
    80007446:	e19c                	sd	a5,0(a1)
  e->prev = lst;
    80007448:	e588                	sd	a0,8(a1)
  lst->next->prev = p;
    8000744a:	611c                	ld	a5,0(a0)
    8000744c:	e78c                	sd	a1,8(a5)
  lst->next = e;
    8000744e:	e10c                	sd	a1,0(a0)
}
    80007450:	6422                	ld	s0,8(sp)
    80007452:	0141                	addi	sp,sp,16
    80007454:	8082                	ret

0000000080007456 <lst_print>:

void
lst_print(struct list *lst)
{
    80007456:	7179                	addi	sp,sp,-48
    80007458:	f406                	sd	ra,40(sp)
    8000745a:	f022                	sd	s0,32(sp)
    8000745c:	ec26                	sd	s1,24(sp)
    8000745e:	e84a                	sd	s2,16(sp)
    80007460:	e44e                	sd	s3,8(sp)
    80007462:	1800                	addi	s0,sp,48
  for (struct list *p = lst->next; p != lst; p = p->next) {
    80007464:	6104                	ld	s1,0(a0)
    80007466:	02950063          	beq	a0,s1,80007486 <lst_print+0x30>
    8000746a:	892a                	mv	s2,a0
    printf(" %p", p);
    8000746c:	00001997          	auipc	s3,0x1
    80007470:	64c98993          	addi	s3,s3,1612 # 80008ab8 <userret+0xa28>
    80007474:	85a6                	mv	a1,s1
    80007476:	854e                	mv	a0,s3
    80007478:	ffff9097          	auipc	ra,0xffff9
    8000747c:	160080e7          	jalr	352(ra) # 800005d8 <printf>
  for (struct list *p = lst->next; p != lst; p = p->next) {
    80007480:	6084                	ld	s1,0(s1)
    80007482:	fe9919e3          	bne	s2,s1,80007474 <lst_print+0x1e>
  }
  printf("\n");
    80007486:	00001517          	auipc	a0,0x1
    8000748a:	e0a50513          	addi	a0,a0,-502 # 80008290 <userret+0x200>
    8000748e:	ffff9097          	auipc	ra,0xffff9
    80007492:	14a080e7          	jalr	330(ra) # 800005d8 <printf>
}
    80007496:	70a2                	ld	ra,40(sp)
    80007498:	7402                	ld	s0,32(sp)
    8000749a:	64e2                	ld	s1,24(sp)
    8000749c:	6942                	ld	s2,16(sp)
    8000749e:	69a2                	ld	s3,8(sp)
    800074a0:	6145                	addi	sp,sp,48
    800074a2:	8082                	ret
	...

0000000080008000 <trampoline>:
    80008000:	14051573          	csrrw	a0,sscratch,a0
    80008004:	02153423          	sd	ra,40(a0)
    80008008:	02253823          	sd	sp,48(a0)
    8000800c:	02353c23          	sd	gp,56(a0)
    80008010:	04453023          	sd	tp,64(a0)
    80008014:	04553423          	sd	t0,72(a0)
    80008018:	04653823          	sd	t1,80(a0)
    8000801c:	04753c23          	sd	t2,88(a0)
    80008020:	f120                	sd	s0,96(a0)
    80008022:	f524                	sd	s1,104(a0)
    80008024:	fd2c                	sd	a1,120(a0)
    80008026:	e150                	sd	a2,128(a0)
    80008028:	e554                	sd	a3,136(a0)
    8000802a:	e958                	sd	a4,144(a0)
    8000802c:	ed5c                	sd	a5,152(a0)
    8000802e:	0b053023          	sd	a6,160(a0)
    80008032:	0b153423          	sd	a7,168(a0)
    80008036:	0b253823          	sd	s2,176(a0)
    8000803a:	0b353c23          	sd	s3,184(a0)
    8000803e:	0d453023          	sd	s4,192(a0)
    80008042:	0d553423          	sd	s5,200(a0)
    80008046:	0d653823          	sd	s6,208(a0)
    8000804a:	0d753c23          	sd	s7,216(a0)
    8000804e:	0f853023          	sd	s8,224(a0)
    80008052:	0f953423          	sd	s9,232(a0)
    80008056:	0fa53823          	sd	s10,240(a0)
    8000805a:	0fb53c23          	sd	s11,248(a0)
    8000805e:	11c53023          	sd	t3,256(a0)
    80008062:	11d53423          	sd	t4,264(a0)
    80008066:	11e53823          	sd	t5,272(a0)
    8000806a:	11f53c23          	sd	t6,280(a0)
    8000806e:	140022f3          	csrr	t0,sscratch
    80008072:	06553823          	sd	t0,112(a0)
    80008076:	00853103          	ld	sp,8(a0)
    8000807a:	02053203          	ld	tp,32(a0)
    8000807e:	01053283          	ld	t0,16(a0)
    80008082:	00053303          	ld	t1,0(a0)
    80008086:	18031073          	csrw	satp,t1
    8000808a:	12000073          	sfence.vma
    8000808e:	8282                	jr	t0

0000000080008090 <userret>:
    80008090:	18059073          	csrw	satp,a1
    80008094:	12000073          	sfence.vma
    80008098:	07053283          	ld	t0,112(a0)
    8000809c:	14029073          	csrw	sscratch,t0
    800080a0:	02853083          	ld	ra,40(a0)
    800080a4:	03053103          	ld	sp,48(a0)
    800080a8:	03853183          	ld	gp,56(a0)
    800080ac:	04053203          	ld	tp,64(a0)
    800080b0:	04853283          	ld	t0,72(a0)
    800080b4:	05053303          	ld	t1,80(a0)
    800080b8:	05853383          	ld	t2,88(a0)
    800080bc:	7120                	ld	s0,96(a0)
    800080be:	7524                	ld	s1,104(a0)
    800080c0:	7d2c                	ld	a1,120(a0)
    800080c2:	6150                	ld	a2,128(a0)
    800080c4:	6554                	ld	a3,136(a0)
    800080c6:	6958                	ld	a4,144(a0)
    800080c8:	6d5c                	ld	a5,152(a0)
    800080ca:	0a053803          	ld	a6,160(a0)
    800080ce:	0a853883          	ld	a7,168(a0)
    800080d2:	0b053903          	ld	s2,176(a0)
    800080d6:	0b853983          	ld	s3,184(a0)
    800080da:	0c053a03          	ld	s4,192(a0)
    800080de:	0c853a83          	ld	s5,200(a0)
    800080e2:	0d053b03          	ld	s6,208(a0)
    800080e6:	0d853b83          	ld	s7,216(a0)
    800080ea:	0e053c03          	ld	s8,224(a0)
    800080ee:	0e853c83          	ld	s9,232(a0)
    800080f2:	0f053d03          	ld	s10,240(a0)
    800080f6:	0f853d83          	ld	s11,248(a0)
    800080fa:	10053e03          	ld	t3,256(a0)
    800080fe:	10853e83          	ld	t4,264(a0)
    80008102:	11053f03          	ld	t5,272(a0)
    80008106:	11853f83          	ld	t6,280(a0)
    8000810a:	14051573          	csrrw	a0,sscratch,a0
    8000810e:	10200073          	sret
